public static class Extensions{
public static void Foo(this string s){}}
string s = "Hello,Word";
s.Foo():
||
Extensions.Poo(s)
实例方法
class person {public void Bar(){}}
person p = new person()
p.Bar();
||
Bar(p) p 为指针
person 被编译器为
void Bar(Parson this);无论是静态方法还是实例方法全部编译为全局代码 ,只是实例方法为全局函数传了个person参数
对象与集合初始化器
public clas Point{ int x,y;public int x{get{return x;}set{x=value}}}
var a = new point{x=0}
||
var a = new point();a.x=0;