110,538
社区成员
发帖
与我相关
我的任务
分享
class Program
{
private static int x;
public static int X
{
get { return x++; }
}
static void Main(string[] args)
{
PlusX(X);
}
public static void PlusX(int value)
{
Console.WriteLine("Value is: {0}", value);
Console.ReadKey();
}
}
class thePlus
{
private int x;
public int X
{
get { return x++; }
}
}
//效果相当于
class thePlus
{
private int x;
public int X
{
get
{
int t = x;
x++;
return t;
}
}
}
class Program
{
static void Main(string[] args)
{
thePlus tp = new thePlus();
PlusX(tp.X);
}
public static void PlusX(int value)
{
Console.WriteLine("Value is: {0}", value);
Console.ReadKey();
}
}
class thePlus
{
private int x;
public int X
{
get { return x++; }
}
}