2013年1月18日
摘要: 问题:为什么c#中要有ref和out?(而java中没有)需求假设:现需要通过一个叫Swap的方法交换a,b两个变量的值。交换前a=1,b=2,断言:交换后a=2,b=1。现编码如下:class Program { static void Main(string[] args) { int a = 1; int b = 2; Console.WriteLine("交换前\ta={0}\tb={1}\t",a,b); Swap(a,b); Console.WriteLine("交换后\ta={0}\tb={1}\t",a,b); Console.Read( 阅读全文
posted @ 2013-01-18 10:24 ltyfat 阅读(117) 评论(0) 推荐(0) 编辑