嘿,我想知道为什么返回类型的事件如
private void button1_Click(object sender, EventArgs e)
Run Code Online (Sandbox Code Playgroud)
永远无效?
它还可以返回任何其他值吗?
当我尝试在表单类中创建表单类的对象时,它会在发生stackoverflow时给出异常.但是,当我在方法中声明表单类的对象时,它工作正常.代码如下:
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
**Form1 f1 = new Form1();**//gives stackoverflow exception.......
char[] ar = new char[15];
int flag = 0, end;
double val1, val2, res;
string oprt;
public Form1()
{
InitializeComponent();
}
private void masters(object sender, EventArgs e)
{
ar[i] = char.Parse(((Button)sender).Text);
if (char.IsDigit(ar[i]))
{
if (flag != 0)
{
if (textBox1.Text == oprt)
{
textBox1.Clear();
}
}
else
{
if (end == 1)
{
textBox1.Clear();
end = 0;
}
}
Button ansbox …Run Code Online (Sandbox Code Playgroud) 我真的在理解事件和委托的概念.我知道委托是持有方法引用的对象,可以调用具有相同返回类型和参数的方法,但那么究竟是什么事件?
如果我需要使用事件来制作一个简单的计算器,那么我该如何使用它们以便有3个事件:一个可以用于数字,一个用于操作符,另一个用于相等或结果操作.