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 .net framework 3.0 (formerly winfx)?
what is entity framework?
What is the greatest advantage of using asp.net mvc over asp.net webforms?
What is basic authentication in web api?
What is entityset? : Entity framework
what is entity sql?
Describe the roles of clr in .net framework.?
How does the .net framework 3.0 relate to windows vista?
what is more complex to implement property, methods or event? how can I define criteria to compare the difficulty of implementation between them? for example the number of methods wanted to implements property is 2 methods. how many methods I need it to implements events?
What are the components required to create a route in mvc?
Explain what is asp.net mvc?
Explain the .net framework.
How to bind table colum with gridview column?
What is namespace of asp.net mvc?
How does servicing work for the .net framework 3.0?