Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Errrhhh ..... CSharp or VB
Message
De
24/09/2011 10:01:33
 
 
À
24/09/2011 08:45:51
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01524423
Message ID:
01524619
Vues:
59
>>>MyName
>>>myName
>>>_myName
>>>this.MyName
>>>
>>>are all valid names but the casing tells you the scope of the variable.
>>
>>Please go on. I sincerely am in learning mode here. What is the scope of each of those?
>
>Here's a sample, I wouldn't do this as a rule, but it illustrates the naming by case.
>
>Field variables i.e. _myName are global to the class in which they are declared but since private are not available outside of class
>Properties (public) are global to the class in which they are declared.and are available to any thing which consumes this class
>Parameters use camel case and are limited in scope to the method
>
>
>
> public class MyClass
>    {
>        private string _myName;
>        public string MyName { get; set; }
>
>        public MyClass(string myName)
>        {
>            _myName = myName;
>
>            this.GetNewName(myName);
>        }
>
>        private void GetNewName(string myName)
>        {
>            this.MyName = _myName + ":" + myName;
>        }
>    }
>
That's one strange class you got there boy :-}
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform