一道很搞的题

https://c.runoob.com/compile/14  在线输入代码验证

using System;
namespace HelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
Model m=new Model();
m.Name="aa";
Console.WriteLine("aa:"+m.GetHashCode());
change(ref m);
Console.WriteLine(m.Name); //输出?

Console.ReadKey();
}
static void change(ref Model m){
//m=new Model();  //1
m.Name="bb";
m=new Model();   //2
//m=null;               //3
////Console.WriteLine("bb:"+m.GetHashCode());

}
}
public class Model
{
public string Name{get;set;}
}
}

1,2处位置互换

3处注释放开

ref去掉

结果分别是什么

猜你喜欢

转载自www.cnblogs.com/xuejianxiyang/p/9264546.html