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

Can we make a class with class with same;suppose public class abc { public class abc { } }

1 Answers  


What is Auto-event wireup? what is the default value for this? when u change the value what will happen?

1 Answers   CMC,


What is the difference between pathparam and queryparam?

0 Answers  


What is a postback ispostback and autopostback in asp net?

0 Answers  


How we can bind textbox,listbox and datagrid to sql server database in asp.net using visualstudio.net language (vb.net)?

2 Answers   rocsearch,






Name some asp objects?

0 Answers  


how can u create the blog in asp.net with C#?what is the data type u will use to store in sql server?

0 Answers   IBM,


About DataAdapters ?

8 Answers   Accenture,


What are the event handlers that can be included in the Global.asax file?

0 Answers   MindCracker,


i have 3+ exp in .net? i am going interview now but they asked me do you know any TOOL? which tool will i study please refer me?

0 Answers   Wipro,


What type of code (server or client) is found in a Code- Behind class?

2 Answers  


how we deploy the asp.net 2.0 application

2 Answers   Logistics,


Categories