what is wrong with this expression?

  • Thread starter Thread starter Carlos
  • Start date Start date
C

Carlos

Hi all, I have the following event function, and the compiler is having a
problem handling negative constant values. What can be happening? Thanks in
advance..



private void button1_Click(object sender, System.EventArgs e)

{

double dME = 0.0;

if ( CB.SelectedItem.Equals("ME") )

{

//erro happens here.. compile says: Invalid expression term ''

dME = -0.1;

}

}
 
--
Artur Borecki, MCP
Carlos said:
Hi all, I have the following event function, and the compiler is having a
problem handling negative constant values. What can be happening? Thanks
in advance..



private void button1_Click(object sender, System.EventArgs e)

{

double dME = 0.0;

if ( CB.SelectedItem.Equals("ME") )

wrong.
Method Equals(object)
"Determines whether the specified Object is equal to the current Object."
(from documentation)

you should write

if (CB.SelectedItem.ToString()=="ME")
{
}
 
Carlos said:
Hi all, I have the following event function, and the compiler is having a
problem handling negative constant values. What can be happening? Thanks in
advance..



private void button1_Click(object sender, System.EventArgs e)

{

double dME = 0.0;

if ( CB.SelectedItem.Equals("ME") )

{

//erro happens here.. compile says: Invalid expression term ''

dME = -0.1;

}

}

I get no error when compiling your code. How many variables/objects named
"dME" do you have?
 
Back
Top