Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ReadOnly Property vs ReadOnly Fields
Message
De
03/10/2007 09:40:55
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
01257644
Message ID:
01258200
Vues:
11
Kevin,

>What's the difference between:
>
>
>  public readonly string MyString;
>
>
>and
>
>
>  public string MyString
>  {
>    get
>    {
>      return foreMyStringName;
>    }
>  }
>
In this case the property is read only. It is a better habit if you need the value to be public to use properties because you have control over the access. Additionally you can do some processing or retrieve a value from another object the containing class has access to.
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform