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 sealed class in c#?

528


how to stored and retrive video in Sql server using asp.net c#......?

535


What is difference between .net and c#?

479


What is use of console?

475


If the original method is not static you can declare an override method to be static or not?

511






How long does it take to get a loop recorder put in?

469


What is CLR and its application.?

574


Is it possible to force garbage collector to run?

490


Name some properties of array.

491


What is difference between struct and class in c#?

483


Is c# and c same?

513


What is difference between constants and read-only?

452


Is static class thread safe in c#?

485


What is iqueryable and ienumerable in c#?

521


What is a function c#?

495