Hey, man, kudos to you for not thinking it was the language that was
broken.... :-)

"'Tis the poor workman who blames his tools."

Ted Neward
{.NET || Java} Course Author & Instructor, DevelopMentor
(http://www.develop.com)
http://www.javageeks.com/tneward
http://www.clrgeeks.com/tneward

----- Original Message -----
From: "Wareham, Matt" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 16, 2002 3:26 PM
Subject: Re: [DOTNET] C# Nesting an If/Else inside of an If/Else???


> Blast... thanks for reading between the lines, I was stepping through the
> code in the debugger.  And, of course as everyone else pointed out the
value
> was correct, the debugger was simply acting like it went through many
lines
> of code.
>
> Thanks for everyone's help!!
>
> -Matt
>
>
> -----Original Message-----
> From: Sean Greer (SBI-Chico) [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 16, 2002 2:47 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] C# Nesting an If/Else inside of an If/Else???
>
> You're not doing anything wrong.
>
> When I run this code it correctly spits out "Yabba Dabba Doo.".  Are you
> seeing something different?  Are you stepping through this code in the
> debugger?  If so, the debugger is known to "step through" single line else
> statements, even though they are not actually evaluated.
>
> Seang
>
> -----Original Message-----
> From: Wareham, Matt [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 16, 2002 2:22 PM
> To: [EMAIL PROTECTED]
> Subject: [DOTNET] C# Nesting an If/Else inside of an If/Else???
>
>
> Greetings,
>
> I'm having some massive confusion over how to properly nest If/Else
> statements in C#.... meaning can it even be done??  Below is a test method
I
> wrote to re-create what I'm thinking is an error.  If you run the code
> below, it will run through both assignments of strResult in the second
> If/Else group.
>
> I can get this to work correctly if I remove the first Else statement at
the
> bottom of the code (the one that says strResult = "Doh.";).  But of course
> doing this defeats the purpose of what I'm trying to do.
>
> Has anyone else run into this problem?  What am I doing wrong???
>
> Thanks,
>
> -Matt
>
>
>
> private void TestIfElse()
> {
>   string strT = "TEST";
>   string strX = "Test Again";
>   string strResult;
>   if (strT.Length > 0)
>   {
>     if (strX.Length > 3)
>     {
>       strResult = "Yabba Dabba Doo.";
>     }
>     else
>     {
>       strResult = "Yadda Yadda Yadda.";
>     }
>   }
>   else
>   {
>     strResult = "Doh.";
>   }
> }
>
> This e-mail message, including any attachments, is for the sole use of the
> intended recipient(s) and may contain confidential or privileged
> information.  Any unauthorized review; use, disclosure or distribution is
> prohibited.  If you are not the intended recipient, please contact the
> sender by reply e-mail and destroy the message.
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
> This e-mail message, including any attachments, is for the sole use of the
> intended recipient(s) and may contain confidential or privileged
> information.  Any unauthorized review; use, disclosure or distribution is
> prohibited.  If you are not the intended recipient, please contact the
> sender by reply e-mail and destroy the message.
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to