What is ReadOnly?
-
I had a strong belief that when a property of an Object is defined as ReadOnly then it means that you can only read its value at runtime and cannot modify the value. If this is wrong just donot read further, but just correct me. This is what I found confusing... In MSDN's documentation for Style property of a Web Control it says,... [Visual Basic] Public ReadOnly Property Style As CssStyleCollection [C#] public CssStyleCollection Style {get;} ... But then they have shown an example of how to use the "visibility" key of the CssStyleCollection to hide and unhide a label control programmatically, like this.... void Button1_Click(Object sender, EventArgs e) { Label1.Style["visibility"]= ((Label1.Style["visibility"]=="hidden")?"show":"hidden"); } If one is able to change a property's value then why the hell do they declare it as *ReadOnly*. And if you are a C# programmer, check out their declaration above that they dont have the set() method. Then how does it work???:confused: omkamal
-
I had a strong belief that when a property of an Object is defined as ReadOnly then it means that you can only read its value at runtime and cannot modify the value. If this is wrong just donot read further, but just correct me. This is what I found confusing... In MSDN's documentation for Style property of a Web Control it says,... [Visual Basic] Public ReadOnly Property Style As CssStyleCollection [C#] public CssStyleCollection Style {get;} ... But then they have shown an example of how to use the "visibility" key of the CssStyleCollection to hide and unhide a label control programmatically, like this.... void Button1_Click(Object sender, EventArgs e) { Label1.Style["visibility"]= ((Label1.Style["visibility"]=="hidden")?"show":"hidden"); } If one is able to change a property's value then why the hell do they declare it as *ReadOnly*. And if you are a C# programmer, check out their declaration above that they dont have the set() method. Then how does it work???:confused: omkamal
In this example they do not change the Style property - they change the value of one of the items in collection that is pointed to by Style property.