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 meaning of console writeline in c#?

439


What is pure abstract class in c#?

447


Can you specify an access modifier for an enumeration?

504


What does immutable mean in c#?

501


Explain boxing and unboxing in c#?

501






What is difference between private and static constructor?

456


Is c# an open source?

488


What is byte c#?

440


Explain the difference between // comments, /* */ comments and /// comments?

489


Does c# do array bounds checking?

530


How many classes are there in classification?

504


What Is A Satellite Assembly?

530


How do I create multifile assembly?

498


What is the use of system.environment class in c#.net?

511


What is difference between private and protected?

493