what is read only and constant

Answer Posted / vathsala

A quick synopsis on the differences between 'const'
and 'readonly' in C#:

'const':
1.Can't be static.
2.Value is evaluated at compile time.
3.Initiailized at declaration only.

'readonly':
1.Can be either instance-level or static.
2.Value is evaluated at run time.
3.Can be initialized in declaration or by code in the
constructor.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by saying a "struct is a value type"?

522


What are the Configuration files in .net?

515


Name some properties of thread class.

554


What is option parameter in C#?

561


What is the and operator in c#?

495






how encapsulation is implemented in c#

643


Can dictionary have duplicate keys c#?

505


Explain partial class in c#?

503


Explain About namespaces

579


Can enum have methods c#?

493


What is the difference between array and arraylist c#?

468


What is the components of window?

506


Does c# do array bounds checking?

543


Can we customize the serialization process?

527


Difference between StackPanel and RelativePanel ?

582