using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace 值传递和引用传递
{internal class Program{static void Main(string[] args){person P1=new person();P1.name = "张三";person P2 = P1;P2.name = "李四";Console.WriteLine(P1.name);Console.WriteLine(P2.name);//拆装箱int n = 10;object o = n;int nn = (int)o;//拿什么装的拿什么拆// double oo = (double)o;double oo = (double)nn;Console.WriteLine(nn);Console.WriteLine(oo);Console.ReadKey();}public class person {public string name{get;set;}}}
}
代码分析1
创建对象:
person P1 = new person(); 创建一个新的 person 对象,并将 P1 设置为引用该对象。