how to return the opposite value of bool?

  • Thread starter Thread starter Tee
  • Start date Start date
T

Tee

Hi,

In VB, we have something called "not" ...
MessageBox.Show(not object.Visible) will return true if it's false and vice
versa.

is there any way we can do the same in c# ?
I tried to use !, but it doesn't work ...
Anyone can help?

Thanks,
Tee
 
Tee said:
In VB, we have something called "not" ...
MessageBox.Show(not object.Visible) will return true if it's false and vice
versa.

is there any way we can do the same in c# ?
I tried to use !, but it doesn't work ...

It should work, although you'll need to convert the bool to a string,
of course. ! is definitely the operator you're after.
 
Hi,

Try
MessageBox.Show( (!object.Visible).ToString() );

It should work fine

Cheers,
 
Thank you all for the reply.
I got it to work, previously just don't know why it won't work.

Thanks
 
Back
Top