What is the difference between readonly and const

Answer Posted / chandan kumar

The read only keyword is different from the const keyword. A
const field can only be initialized at the declaration of
the field. A read only field can be initialized either at
the declaration or in a constructor. Therefore, read only
fields can have different values depending on the
constructor used. Also, while a const field is a
compile-time constant, the read only field can be used for
runtime constants as in the

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the ouput of the following program?

762


I was trying to use an out int parameter in one of my functions. How should I declare the variable that I am passing to it?

774


Is lazy thread safe c#?

699


What is attribute and reflection in c#?

710


Explain the role of the datareader class in ado.net connections?

693


Can a static class contain non static members?

779


Can hashtable have duplicate keys in c#?

663


what are pointer types in c#

774


What is static variable in c#?

712


What is an int c#?

657


Is there an equivalent to the instanceof operator in visual j++?

771


What is a satellite assembly in c#?

789


What is the difference between c and c sharp?

751


What is difference between ienumerable and list in c#?

673


Give examples for reference types?

766