当前位置: 代码迷 >> 综合 >> C# this 关键字
  详细解决方案

C# this 关键字

热度:72   发布时间:2024-01-30 03:54:41.0
  • 用在类的属性、实例方法或实例构造方法中,区分成员名和本地变量(或参数)。this.XXX 
  • 表示当前对象。 传递参数的时候,可以直接用。
  • 索引器
    class Rectangular{public float x;public float y;public float this[int index]{set{switch (index){case 0:this.x = value;break;case 1:this.y = value;break;}}}}

    Rectangular rect =new Rectangular ();

    rect[0] =1;

 

 

 

  相关解决方案