static void Main(string[] args)
{
int myInt = 12345678;
MyExtensions.DisplayDefiningAssembly(myInt);
System.Data.DataSet ds = new System.Data.DataSet();
MyExtensions.DisplayDefiningAssembly(ds);
System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
MyExtensions.DisplayDefiningAssembly(sp);
Console.WriteLine("Value of myInt: {0}", myInt);
Console.WriteLine("After reversed: {0}", MyExtensions.ReverseDigits(myInt));
MyExtensions.Foo(myInt);
MyExtensions.Foo(myInt, "This is the sample provided by SpadeQ!");
Console.ReadLine();
}
运行结果仍然是一样的。也就是说,从某个对象调用扩展方法,看起来像是实例级别的调用,其实是编译器在忽悠我们而已~~~
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12641349/viewspace-145390/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12641349/viewspace-145390/