I corrected the parenthesis problem. Still I have similar code blocks
where ELSE is not needed.
So, something like:
if ((txtMethod.Text == "D") || (txtMethod.Text == "F"))
will not work. I have written this on TextChange event. If the text
type is not D or not F then clear it, else do the ELSE part.
> Well, you didn't specify what problem you're having, but the code
> above won't compile - you're missing an open parenthesis. Also, your
[quoted text clipped - 19 lines]
>
> Michael
Jon Skeet [C# MVP] - 29 Aug 2007 19:05 GMT
> I corrected the parenthesis problem. Still I have similar code blocks
> where ELSE is not needed.
[quoted text clipped - 4 lines]
> will not work. I have written this on TextChange event. If the text
> type is not D or not F then clear it, else do the ELSE part.
I don't see why that wouldn't work.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
mpetrotta@gmail.com - 29 Aug 2007 19:13 GMT
> I corrected the parenthesis problem. Still I have similar code blocks
> where ELSE is not needed.
[quoted text clipped - 4 lines]
> will not work. I have written this on TextChange event. If the text
> type is not D or not F then clear it, else do the ELSE part.
No. The condition you've stated ("if the text is not D or not F")
will not work. Think about it; say you've got:
if ((txtMethod.Text != "D") || (txtMethod.Text != "F"))
You want that to resolve to false when txtMethod is "D", for
instance. What you'll actually see is:
if (( "D != "D") || ("D" != "F"))
which resolves to:
if ( false || true)
which resolves to true.
See my earlier reply for what you likely want to do. In general,
though, it's worthwhile to "run" your algorithms in your mind with
test cases, to see if they do the right thing. Also, while English
often treats "and" and "or" as equivalent, boolean algebra definitely
does not.
Michael