有如下的程序 :
private void button1_Click(object sender, EventArgs e)
{
int a = 0;
sd(a);
textBox1.Text = a.ToString();
}
private void sd(int b)
{
b =b+ 1;
}
程序运行之后,结果并不是我想象的1,而是0,这是怎么回事呢?
private void button1_Click(object sender, EventArgs e)
{
int a = 0;
sd(a);
textBox1.Text = a.ToString();
}
private void sd(int b)
{
b =b+ 1;
}
程序运行之后,结果并不是我想象的1,而是0,这是怎么回事呢?
{
int a = 0;
textBox1.Text = sd(a).tostring();
}
private int sd(int b)
{
return b+ 1;
}
private void button1_Click(object sender, EventArgs e)
{
int a = 0;
sd(ref a);
textBox1.Text = a.ToString();
}
private void sd(ref int b)
{
b =b+ 1;
}
private void button1_Click(object sender, EventArgs e)
{
int a = 0;
sd(out a);
textBox1.Text = a.ToString();
}
private void sd(out int b)
{
b =b+ 1;
}
private int sd(int b)
{
return b = b + 1;
}
private void button1_Click(object sender, EventArgs e)
{
int a = 0;
sd(ref a);
textBox1.Text = a.ToString();
} private void sd(ref int b)
{
b += 1;
}