111,129
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
string x = "1";
string y = "2";
string x0 = "1";
string y0 = "2";
int x1 = 1;
int y1 = 2;
int x2 = 1;
int y2 = 2;
XXX(ref x,ref y);
XXX(x0, y0);
XXX(ref x1,ref y1);
XXX(x2, y2);
string result="x:"+x + " y:" + y+"x0:"+x0+" y0:"+y0+"x1:"+ x1 + " y1:" + y1+"x2:"+x2+" y2:"+y2;
MessageBox.Show(result);
}
void XXX(string x,string y)
{
string t = null;
t = x;
x = y;
y = t;
}
void XXX(ref string x, ref string y)
{
string t = null;
t = x;
x = y;
y = t;
}
void XXX(int x,int y)
{
int t = 0;
t = x;
x = y;
y = t;
}
void XXX(ref int x, ref int y)
{
int t = 0;
t = x;
x = y;
y = t;
}
static void Main()
{
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
List<string> lst = new List<string>();
lst.Add("1");
lst.Add("2");
Console.WriteLine(string.Format("First:{0},Second:{1}",lst[0],lst[1]));
XXX(lst);
Console.WriteLine(string.Format("First:{0},Second:{1}", lst[0], lst[1]));
}
public static void XXX(List<string> lst)
{
lst[0] = "5";
lst[1] = "6";
}
void XXX(ref int x, ref int y)
{
int t = 0;
t = x;
x = y;
y = t;
}
void XXX(string x,string y)
{
string t = null;
t = x;
x = y;
y = t;
}
string x = "1";