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; 

 

 

 

 

相关文章:

  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-07-12
猜你喜欢
  • 2021-06-18
  • 2021-06-17
  • 2022-12-23
  • 2021-10-16
  • 2021-10-16
相关资源
相似解决方案