What is the Difference between read only and constant
variables?
Answer Posted / akshay
Constants :
* Constant value. Cannot be changed once initialized.
Should be Initialize the value where it declared.
* Const value fully evaluated at compile time
* By default static
* Possible to declare within function
Readonly :
* Could be declare as Static or Non Static
* Assign the value where it declared or can be assigned in
constructor
* Could not declare within function
* can be initialized in compile time or in runtime.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a multicast c# delegate?
can you allow a class to be inherited, but prevent the method from being over-ridden?
What is difference between first and firstordefault?
What is the lock statement in c#?
What is ildasm and obfuscator in net?
What is inner class in c#?
How to use exception handling in stored procedure?
Are structs faster than classes?
What are value types and reference types?
can multiple catch blocks be executed for a single try statement?
Is c# still popular?
What is difference between ienumerable and list in c#?
Why use a singleton instead of static methods?
What is the difference between CreateObject() and GetObject()?
How Global.asax is used ?