What is the difference b/w Readonly Variable and Constant
Variable?
Answer Posted / niranjan
The readonly keyword differs from the const keyword. 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, although a const field is a compile-
time constant, the readonly field can be used for run-time
constants, as in this line: public static readonly uint l1
= (uint)DateTime.Now.Ticks;
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
How a base class method is hidden?
What are the technology areas that microsoft.net contains?
Explain jit?
What are the features present in vb 2005?
Why do you need Lock in Visual Basic?
Explain the difference between system.string and system.stringbuilder classes?
Explain the use of console application?
What is global assembly cache (gac)?
What is late binding and early binding?
What is the differnce between managed code and unmanaged code?
Write a program to find all text files in a logical drive and return the count of the number of files?
What is the significance of delegates?
Explain option strict?
Can you please explain the difference between dataset and datareader?
What are the assembly entry points?