using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _9对像的引用2{ class Program { static void Main(string[] args) { int i = 10; int j = i; //拷贝 i++; Console.WriteLine(j); //int, datetime,bool,char等类型都属于值类型(ValueType),赋值的时候是传递拷贝 //普通的对则是引用类型,赋值的时候是传递引用 Person p1 = new Person(11); Person p2 = p1;//指向同一个类型 p1.Age++; IncAge(p1); Console.WriteLine(p2.Age);//13 Console.ReadKey(); } static void IncAge(Person s) { s.Age++; } } class Person { public int Age { get; set; } public Person(int age) { this.Age = age; } }}