标签:text hit 返回值 ref read height 实例 lang family
1 //ref传递参数之前必须赋初值 2 static void Main(string[] args) 3 { 4 int a = 10; 5 int b = 20; 6 GetValue(ref a, ref b); 7 Console.WriteLine($"{a} {b}"); 8 Console.ReadKey(); 9 } 10 static void GetValue(ref int x,ref int y) 11 { 12 Console.WriteLine($"{x} {y}"); 13 x = 50; 14 y = 60; 15 }
1 static void Main(string[] args) 2 { 3 //out在这里赋不赋值没影响 4 //int a = 10; 5 //int b = 20; 6 int a, b; 7 GetValue(out a, out b); 8 Console.WriteLine($"{a} {b}"); 9 Console.ReadKey(); 10 } 11 static void GetValue(out int x,out int y) 12 { 13 //out在方法内必须先赋值再用。 14 //Console.WriteLine($"{x} {y}"); 15 x = 50; 16 y = 60; 17 Console.WriteLine($"{x} {y}"); 18 }
结果:
标签:text hit 返回值 ref read height 实例 lang family
原文地址:https://www.cnblogs.com/fanjianzhi/p/12842876.html