static void method7(string x,string y)
{ string z;
z = x;
x = y;
y = z;
}
string s1 = "abc", s2 = "efg";
method7(s1,s2);
Console.WriteLine("s1={0},s2={1}",s1,s2);
为什么交换不了,字符串不是引用类型的么,为什么不能直接引用传递,而必须用ref转换
{ string z;
z = x;
x = y;
y = z;
}
string s1 = "abc", s2 = "efg";
method7(s1,s2);
Console.WriteLine("s1={0},s2={1}",s1,s2);
为什么交换不了,字符串不是引用类型的么,为什么不能直接引用传递,而必须用ref转换
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货