Hi Friends,
Any one tell me what is the difference between static and read only?
Thanks...,
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Jul 15, 2010, 1:48 AM
Hirendra SisodiyaPosted Jul 15, 2010, 1:23 AM
i have not said that static can not be initilized on runtime.Sam you are understanding wrong, perhaps because of my wording (Sorry..)
see this- A read only member is like a constant in that it represents an
unchanging value and than i say The difference is that a readonly member can be initialized at runtime( this difference is respect of Constant not static).
you have already describe exact difference between both, and i think it is enough but i try to expalin both things individually. i try to explain 'Readonly' in the respect of Constant.
thanks
Sam HobbsPosted Jul 14, 2010, 12:05 PM
Hirendra SisodiyaPosted Jul 14, 2010, 4:29 AM
Static member can be accessed without creating an instance of the class. Only one copy of static fields and events exists, and static methods and properties can only access static fields and static events. Static modifier can be used with classes, fields, methods, properties, operators, events and constructors, but cannot be used with indexers, destructors, or types other than classes.
thanks
Please mark as answer if it helps
Sam HobbsPosted Jul 13, 2010, 8:40 PM