C# 代码问题
using System;Class Count
{
static int count;
int number;
public count();
{
count=count+1;
number=count;
}
public show()
{
Console.WriteLine("Object{0}:count={1}",number,count);
}
}
Class Test
{
public static void main()
{
Count a=new Count();
a.show();
Console.WriteLine("--------------------------");
Count b=new Count();
a.show();
b.show();
Count c=new Count();
a.show();
b.show();
c.show();
}
}
结果:
object1:count=1
----------------------------------
object1:count=2
object2:count=2
---------------------------------
object1:count=3
object2:count=3
object3:count=3
这是怎么得来的啊?哪位大虾跟我说下这里面number是怎么变化的呢 谢谢了