What's the difference between const and readonly ?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the benefit of entity framework?

538


What is disconnected scenario? : Entity framework

535


mention what is the key advantage of using entity framework or ef?

557


What is Dependency Injection in ASP.Net MVC

590


what is minimum requirement for entity framework applications to run?

579






What are the major improvements provided by the common language runtime and the base class libraries? Or what are the major improvements in .net framework 4.0?

534


Explain how you can send the result back in JSON format in MVC?

581


What is namespace of asp.net mvc?

605


why DotNetFramework is included in building a software

2220


Explain two instances where routing is not implemented or required?

592


What are the possible razor view extensions?

574


Can we have enum in entity framework?

591


How does �side by side� work for the .net framework 3.0?

532


Please explain me what the project manager will ask in the interview.The interview is for senior position in .Net (5 years experience )

2498


What is the mvc pattern (model view controller pattern)?

584