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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sam HobbsRank #108 · 20.5K reputationPosted Jul 13, 2010, 4:40 PM EDT
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Jul 14, 2010, 12:29 AM EDT
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 HobbsRank #108 · 20.5K reputationPosted Jul 14, 2010, 8:05 AM EDT
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Jul 14, 2010, 9:23 PM EDT
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 HobbsRank #108 · 20.5K reputationPosted Jul 14, 2010, 9:48 PM EDT