this 关键字的用法
using System;class Number
{
public int i;
public Number(int initval)
{
this.i = initval;
}
public static Number operator ++(Number arg)
{
return new Number(arg.i +1);
}
}
class test
{
static void Main()
{
Number Obj1 = new Number(1);
Number Obj2 = Obj1++;
Console.WriteLine(Obj1.i);
Console.WriteLine(Obj2.i);
Obj2 = ++Obj1;
Console.WriteLine(Obj1.i);
Console.WriteLine(Obj2.i);
}
}
上面的代码 this.i = initval; 这里的this 是用作干什么的,我去了this好像也没有错啊