What's the difference between const and readonly ?

Answers were Sorted based on User's Feedback



What's the difference between const and readonly ?..

Answer / kirti

You can initialize readonly variables to some runtime values. Let's say your program uses current date and time as one of the values that won't change. This way you declare public readonly string DateT = new DateTime().ToString().

Is This Answer Correct ?    0 Yes 0 No

What's the difference between const and readonly ?..

Answer / mr vinod kumar

The readonly keyword is different 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, 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;
What does a character do ?
On most systems, produces a rather annoying beep.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net Framework Interview Questions

Can we create .DLL file without using the namespace?

4 Answers  


i have done enough testing in life but now stated developing intereset in development work,Can i think of entering into development work that too in >Net after more then 4 years of testing experiece?

0 Answers  


What are the types of assemblies and where can u store them and how ?

11 Answers   Accenture, BirlaSoft, IBM,


Why do you need to serialize

1 Answers  


What are the mobile devices supported by .net platform

1 Answers  






give the feature of .net2.0 over .net1.1

6 Answers  


What is serialization in .NET? What are the ways to control serialization?

2 Answers  


Which is the base class for .net Class library?

12 Answers   Sonata, TCS,


Is any files are generated,when we are adding the web reference to the web service?

1 Answers  


Explain JSON Binding?

0 Answers  


What is display mode in mvc?

0 Answers  


What is html.renderpartial?

0 Answers  


Categories