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


Please Help Members By Posting Answers For Below Questions

Can you please explain the difference between namespace and assembly?

725


What is the significance of delegates?

692


What is meant by jagged arrays?

752


What is sorting in vb?

660


What is a stream in vb.net?

732


What is the advantage of using system.text.stringbuilder over system.string?

817


what is difference between web.config and machine.config and where it will be ?

691


Define clr?

719


Explain about branching logic control in vb.net?

703


What is pre-jit?

706


Why should you use delegate?

649


What is the difference between c# and vb.net?

748


What is the use of console application?

765


What is sealed class?

796


Explain how does the xmlserializer work?

762