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 the benefit of entity framework?
How does the 'page lifecycle' of asp.net mvc works?
What are html helpers in asp.net mvc?
Explain the methods used to render the views in mvc?
how to disable the lazy loading framework?
What are the main components of .net framework?
What is associationset? : Entity framework
Difference between ASP.NET MVC and ASP.NET WebForms?
explain what does .edmx file contains?
What is model first? : Entity framework
How do you assign a value to a complex number 7 how has exception hand changed in .net framework 4.0?
What are the 2 popular asp.net mvc view engines?
Why should we go for entity framework?
Explain representational state transfer (rest) in detail?
Explain what is asp.net mvc?