标签:style blog color ar sp div on log bs
ref:
变量需赋值,值带入方法,参与逻辑运算,最终对相应变量赋值;
out:
变量值不带入方法,参与逻辑运算,最终对相应变量赋值;
int.tryparse(string s,out int n) //用out不用ref
示例:
private void RefAndOut(ref int i,out int j) { i++; j++; } int i = 1; int j = 2; RefAndOut(ref i,out j); Console.WriteLine("i="+i); Console.WriteLine("j="+j);
结果:
----------------------- i=2; j=1; -----------------------
标签:style blog color ar sp div on log bs
原文地址:http://www.cnblogs.com/raowenbin/p/4055507.html