Func和Action
private void button7_Click(object sender, EventArgs e)
{
Action<int, int> action = (x, y) => {
MessageBox.Show((x+y).ToString());
};
action(1, 2);
}
private void button11_Click(object sender, EventArgs e)
{
Action<int, int> action = delegate(int x, int y)
{
MessageBox.Show((x + y).ToString());
};
action(1, 2);
}
private void button8_Click(object sender, EventArgs e)
{
Func<int, int, int> func = (x, y) =>
{
return x + y;
};
int result = func(1, 2);
MessageBox.Show(result.ToString());
}
private void button9_Click(object sender, EventArgs e)
{
Action action = delegate()
{
MessageBox.Show("Hello.");
};
action();
}
private void button10_Click(object sender, EventArgs e)
{
Action action = () =>
{
MessageBox.Show("Hello.");
};
action();
}
{
Action<int, int> action = (x, y) => {
MessageBox.Show((x+y).ToString());
};
action(1, 2);
}
private void button11_Click(object sender, EventArgs e)
{
Action<int, int> action = delegate(int x, int y)
{
MessageBox.Show((x + y).ToString());
};
action(1, 2);
}
private void button8_Click(object sender, EventArgs e)
{
Func<int, int, int> func = (x, y) =>
{
return x + y;
};
int result = func(1, 2);
MessageBox.Show(result.ToString());
}
private void button9_Click(object sender, EventArgs e)
{
Action action = delegate()
{
MessageBox.Show("Hello.");
};
action();
}
private void button10_Click(object sender, EventArgs e)
{
Action action = () =>
{
MessageBox.Show("Hello.");
};
action();
}