日期:2014-05-18 浏览次数:21389 次
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("ad阿斯顿发发呆fa".a());
Console.ReadKey();
}
}
static public class X
{
public static int a(this string s)
{
return s.Length;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
public sealed class ExtensionAttribute : Attribute { }
}
------解决方案--------------------
不管你使用vs2008还是vs2010(当然最好使用最新的),创建一个.net2.0目标平台的项目,然后就可以编译发布了。难道你为了编译一个.net2.0下的程序,还要再次安装古老的vs2005?不需要哦。
而你编写的.net2.0下的程序所用的语法,不是c#2.0的,而是c#3.0的或者c#4.0的。你的c#语言的版本跟目标.net平台版本没有关系。