public class DicTestClass
{
public DicTestClass(int a)
{
mAA = a;
}
public int mAA = 0;
}
public static void SwapRightListItem(ref DicTestClass left, ref DicTestClass right)
{
DicTestClass temp = null;
temp = right;
right = left;
left = temp;
}
static void Main(string[] args)
{
DicTestClass aaa = new DicTestClass(1);
DicTestClass bbb = new DicTestClass(2);
SwapRightListItem(ref aaa, ref bbb);
Console.WriteLine(" aaa:" + aaa.mAA);
Console.WriteLine(" bbb:" + bbb.mAA);
}
上面的代码:输出值是2,1 如果全去掉ref 输出值是1,2
为什么? class不已经是引用类型了吗???
- 1 回答
- 0 关注
- 721 浏览
添加回答
举报
0/150
提交
取消