Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Local variable
Message
 
 
To
10/01/2009 21:21:39
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01372518
Message ID:
01372622
Views:
15
Yes, I was thinking the same. May be he meant || or condition ?

>John,
>
>Your example won't ever work correctly. See my comment below:
>
>
>       bool retVal = false;
>
>       // this.MyMethodB() will never execute because of the fact
>       // that retVal is already false.
>       retVal = retVal && this.MyMethodB();
>
>
>so, I guess you need a different example to explain your problem.
>
>~~Bonnie
>
>
>>Hi,
>>Thank you for reply.
>>
>>Actually I am not using string. I just use it as example. Below is my sample code":
>>
>>
>>
>>public class MyClass
>>{
>>    public bool MyMethodA()
>>    {
>>        bool retVal = false;
>>        //Do Soemthing
>>
>>       retVal = retVal && this.MethodB();
>>       return retVal;
>>    }
>>
>>    public bool MyMethodB()
>>    {
>>        bool retVal = false;
>>        //Do Something
>>        retVal = 1 + 1 > 0;         //Example
>>
>>        if (retVal)                       // Weird
>>        {
>>            retVal = 2 + 2 > 0;     // Example
>>        }
>>
>>        return retVal;
>>    }
>>}
>>
>>
>>when I debug, the retVal at //Weird will compare wrongly. If I change retVal at MethodA to other name, then the problem will be gone. At idea?
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform