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

Why do we use inheritance in c#?

571


Is c# good for web development?

634


What is default class in c#?

577


What is Named parameter in C#?

632


Where static variables are stored?

550






How do I create a multilanguage, single-file assembly?

580


Can we set image Source dynamically using C# in WPF application?

724


What is the root element of an xml file?

582


What is the difference between method and constructor in c#?

551


What is console writeline in c#?

560


What is c# best for?

611


How do I enforce const correctness in c#?

609


What is protected internal modifier in C#?

616


Can you access a hidden base class method in the derived class?

590


What is the benefit of delegate in c#?

579