namespace ConsoleApplication1{
class Program{
static void Main(string [] args ){
ReferenceAndValue.Demonstration(); //调用ReferenceAndValue中的Demonstration方法
}
}
public class stamp{ //定义一个类
public string Name{get; set;} //定义引用类型
public int Age{get;set;} //定义值类型
}
public static class ReferenceAndValue{ //定义一个静态类
public static void Demonstration(){ //定义一个静态方法
stamp Stamp_1=new stamp{Name=‘‘Premiere",Age=25} //实例化
stamp Stamp_2=new stamp{Name=‘‘Again",Age=47} //实例化
int Age=Stamp_1.Age; //获取值类型Age的值
Stamp_1.Age=22; //修改值类型的值
stamp guru=Stamp_2; //获取Stamp_2中的值
Stamp_2.Name="Again Amend";//修改引用的Name值
Console.writeLine("Stamp_1‘s age:{0}"Stamp_1.Age);//显示Stamp_1中的Age值
Console.writeLine("age‘s value:{0}",age);//显示age的值
Console.writeLine("Stamp_2‘s name:{0}"Stamp_2.Name)//显示Stamp_2中的Name的值;
Console.writeLine("guru‘s name:{0}",guru.Name);
}
}
}