What is the difference b/w constant & read only variable?
Answer Posted / maloy.adhikari
Constants: The value can't be changed
Read-only: The value will be initialized only once from the
constructor of the class.
Const:
1)Can not be static.
2)The value is evaluated at compile time.
3)It is initialized at declaration only.
4)the const keyword is used for compile-time constants
Readonly:
1)Can be either instance-level or static.
2)The value is evaluated at run time.
3)It can be initialized in declaration or by code in the
constructor. Therefore, readonly fields can have different
values depending on the constructor used.
4)the readonly keyword is used for runtime constants.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is edm designer? : Entity framework
What are Action Methods in ASP.NET MVC?
What are the advantages of razor view engine?
What is entitytypes? : Entity framework
Explain covariance and contra-variance in .net framework 4.0. Give an example for each.
What is the .net framework and how does it work?
What are ajax helpers in mvc?
Can we have enum in entity framework?
What are the components required to create a route in mvc?
What are scaffold templates in mvc?
What is entity framework firstordefault?
What are actions in asp.net mvc?
How to enable Attribute Routing?
What is layout in mvc?
What is an asynchronous controller in asp.net mvc?