Answer Posted / xiaof
A const field can only be initialized at the declaration of
the field. A readonly field can be initialized either at
the declaration or in a constructor. Therefore, readonly
fields can have different values depending on the
constructor used. Also, while a const field is a compile-
time constant, the readonly field can be used for runtime
constants as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks;
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is a static in c#?
What's the difference between an integer and int?
Can a class be protected in c#?
What is the resgen.exe tool used for?
What are the variables in c#?
What is the difference between a private assembly and a shared assembly?
Why we need get set property in c#?
What does writeline mean?
What is single dimensional array in c#?
Are cao stateful in nature?
What is a template class?
How to declare a property in a class?
What is the use of generics in c#?
What is class sortedlist underneath?
What is difference between first and firstordefault?