Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IF conditional coding
Message
De
06/09/2005 12:39:26
 
 
À
06/09/2005 08:55:50
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Divers
Thread ID:
01046886
Message ID:
01047068
Vues:
13
Hilmar,

>Also, the keyword this is not required in many cases, although it can help with Intellisense.<

That is one of my pet peeves ... people who do NOT use "this". The use of "this" makes it quite simple to tell the difference between a variable scoped to the whole control vs one scoped to the method. IMHO, one should always use "this".

~~Bonnie


>By the way, the equivalent of the iif() from VFP would be like this:
>
>
>TitleLabel.Visible = TitleCheckBox.Checked ? true : false
>
>
>? : is a basic operator - a triadic one.
>
>In this particular case, since we already have a value of type bool, the direct assignment (as shown in another reply in this thread) is simpler, of course.
>
>Also, the keyword This is not required in many cases, although it can help with Intellisense.
>
>Doesn't the compiler complain if you use "=" instead of "==" in the if()?
>
>>I am new to C#, off and on for a couple years.
>>
>>I am trying to make a label visible by using a check box, but I cannot seem to figure out how to code it.
>>
>>Here's my code, but it doesn't work:
>>
>>
>>        private void titleCheckBox_CheckedChanged(object sender, EventArgs e)
>>        {
>>            if (this.titleCheckBox.Checked = true)
>>            {
>>                this.titleLabel.Visible = true;
>>            }
>>            else
>>            {
>>                this.titleLabel.Visible = false;
>>            }
>>
>>        }
>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform