Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Local variable
Message
 
 
À
10/01/2009 21:21:39
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01372518
Message ID:
01372622
Vues:
16
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform