what is difference between const, static and readonly?

Answers were Sorted based on User's Feedback



what is difference between const, static and readonly?..

Answer / magesh

const variable : const can never be modified and
must be initialized to a compile time constant.

Static variable : you received last updated value, when u
getting value for static variable.

Readonly variable : The readonly variable can be changed
inside the constructor.

Is This Answer Correct ?    7 Yes 0 No

what is difference between const, static and readonly?..

Answer / amit manekar

The difference is that static read-only can be modified by
the containing class, but const can never be modified and
must be initialized to a compile time constant. To expand on
the static read-only case a bit, the containing class can
only modify it:

in the variable declaration (through a variable initializer).

in the static constructor (instance constructors if it's not
static).

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More ASP.NET Interview Questions

Explain transparent caching with aop?

0 Answers  


How many web config files can be created for an application?

0 Answers  


can s/w quality assurance engineer switch field to programming side i m very much interested in programming but not much good in it

0 Answers  


how we deploy the asp.net 2.0 application

2 Answers   Logistics,


if you disable view state of a textbox will it maintain data during postbacks.if yes reason

9 Answers   FactorH, Jindal, Oxi Infotech,






How we can kill our Session in web farm where there is no any sticky server .And user can not Logout bcoz of that.

3 Answers  


Types of optimization and name a few and how do u do?

1 Answers   Accenture,


Which method is used to force all the validation controls to run?

0 Answers  


How does the iis work?

0 Answers  


What is the use of directives & explain with example?

2 Answers   C Squared Systems,


Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?

2 Answers   Siebel Systems,


What are the various security methods which IIS Provides apart from .NET ?

1 Answers  


Categories