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 version number for the next version of the .net framework, codenamed �orcas�?
How does the .net framework 3.0 relate to the .net framework 2.0?
What is route config?
How we can register the Area in ASP.Net MVC?
why DotNetFramework is included in building a software
How can we determine action invoked from HTTP GET or HTTP POST?
What is NonActionAttribute ?
How do you handle variable number of segments in a route definition?
Explain JSON Binding?
Explain tempdata in asp.net mvc?
What is Peek method in Tempdata in ASP.Net MVC?
Which version of .net framework is installed?
What is meant by viewdata?
What is session state management?
Explain something about model, view and controllers in asp.net mvc?