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 tempdata?
What are ajax helpers in mvc?
what is .edmx file and what it contains?
Describe the .net framework architecture.
How to use Jquery Plugins in ASP.Net MVC validation?
What is .net core framework?
What is entitycontainer? : Entity framework
What is mvc entity framework?
How do I install .net framework?
i just want to write an exam regarding .net?plz give me information about taking a test?where to pay 4 d exam,exam centre?
What are the options can be configured in AJAX helpers?
Explain how to use multiple submit buttons in ASP.Net MVC?
How does .net framework works?
what is split entity?
Can you explain renderbody and renderpage in mvc?