1 string str1=Console.ReadLine();//键盘输入的默认为字符串 2 Console.WriteLine("a={0},b={1}",a,b) 3 int a1=int.Parse(str1); //字符串转为数值
for(i=3;i<=10;i++) //for 的格式 { }
1 static void Swap(inta,intb)//存疑,可能不是值传递 2 { 3 int t;//t的作用范围尽在此大括号内 4 t=a;a=b;b=t; 5 } 这样在主函数中交换a,b需要 static void Main(string[] args) int a=1; int b=2; Swap(ref a, refb) 这样在主函数中交换a,b需要 Swap(a,b) 另外一种写法: //ref共用内存 1 static void Swap(ref int a,ref int b)// 2 { 3 int t;//t的作用范围尽在此大括号内 4 t=a;a=b;b=t; 5 } 这样在主函数中交换a,b需要 static void Main(string[] args) int a=1; int b=2; Swap(ref a, refb)
1 static void Swap(ref int a,ref int b) //交换两个数 2 static void Swap(ref string a,ref string b) //交换两个字符串
原文:https://www.cnblogs.com/xdd1997/p/11219434.html