Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ReadOnly Property vs ReadOnly Fields
Message
From
03/10/2007 09:40:55
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01257644
Message ID:
01258200
Views:
13
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
Previous
Reply
Map
View

Click here to load this message in the networking platform