Hi , I am trying to check the status of a button final in following code.its giving me "1 Operator '||' cannot be applied to operands of type 'bool' and System.Windows.Forms.DialogResult'.Is there any other way to perform this operation.
Code:
private void Value7_Click(object sender, EventArgs e)
{
int n = 7;
int i = int.Parse(textBox1.Text);
if ( (i = = 0) || (final.DialogResult = = DialogResult.OK ))
{
textBox1.Text = n.ToString();
}
else
{
textBox1.Text += n.ToString();
}
}
thanx in advance.

Button Status
bjorneb
Hi Kiran
In C# a test for equality is == not =space= -- pasting your code into a test block it compiled fine with == for both tests.
int n = 7; int i = int.Parse(textBox1.Text); if ( (i == 0) || (final.DialogResult == DialogResult.OK )){
textBox1.Text = n.ToString();
}
else{
textBox1.Text += n.ToString();
}
Since you only have one element in the if/else you can save some typing by shortening this to:
int n = 7; int i = int.Parse(textBox1.Text); if ( (i == 0) || (final.DialogResult == DialogResult.OK ))textBox1.Text = n.ToString();
elsetextBox1.Text += n.ToString();
.net's compiler is much smarter than most!
HTH
Anatoly Borisov