日期:2014-05-17 浏览次数:20505 次
public class People
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
static void Main(string[] args)
{
People p1 = new People();
p1.Name = "张三";
People p2 = p1;
p2.Name = "李四";
int int1 = new int();//初始化时值默认为0
int int2 = int1;
int2 = 3;
Console.WriteLine(int1);
Console.WriteLine(int2);
Console.WriteLine(p1.Name);
Console.WriteLine(p2.Name);
Console.Read();
}
public void static Main()
{
int i=1;
ChangeValue(ref i);
Console.WriteLine(i);
}
public void static ChangeValue(ref int x)
{
x=4;//此时对变量x的操作会影响到Main中的i变量
}