1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ConsoleApplication7 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 int a = 10; 14 int b = 15; 15 Test(ref a, ref b); 16 Console.WriteLine("现在a的值是{0},b的值是{1}",a,b); 17 Console.ReadKey(); 18 } 19 20 static int Test(ref int a,ref int b) 21 { 22 int temp = a; 23 a = b; 24 b = temp; 25 return 20; 26 } 27 28 29 } 30 }