Difference Between ReadOnly and Constant Variable in
compile time and Run Time.

Answers were Sorted based on User's Feedback



Difference Between ReadOnly and Constant Variable in compile time and Run Time...

Answer / karna

I am adding another point to the above answer.

as the constant variable is constant over the class,that
means,all the objects created for that class have the same
value.
but in case of readonly variables,we can assign different
values in the different instances of the class it contains.

Is This Answer Correct ?    6 Yes 0 No

Difference Between ReadOnly and Constant Variable in compile time and Run Time...

Answer / kamlesh sharma

readonly variables are can be initilized at compile time
but we can assign values to readonly varialble at once
through functions or constructors

but in case of constant variables once assign a value we
can't change value and must assign value to constant
variables at the time of declarition

Is This Answer Correct ?    5 Yes 1 No

Difference Between ReadOnly and Constant Variable in compile time and Run Time...

Answer / saiish bhat

readonly is compile time constant.
constant is runtime constant.

constatnt field is used to initialize at the declaration of
the field.
readonly field is used at the declaration or constructor of
the field.

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More ASP.NET Interview Questions

Can we change the session timeout in ASP.NET, if yes then how and from where?

7 Answers   L&T,


Can a user browsing my Web site read my Web.config or Global.asax files ?

1 Answers  


What is event bubbling?

0 Answers  


To display data in the combo box, prior to setting the Data Source, what kind of property on a Combo Box do you set with a column name?

0 Answers   Siebel,


What is an example of an application service provider?

0 Answers  






In which interface the template of any control like Gridview would Initiate?

2 Answers  


Various types of Page Load functions

4 Answers   Net Solution,


define silverlight and advantages ?

3 Answers   QA,


Which tab of the web site administration tool do you use to manage application setting ,debug and tracing?

2 Answers  


Is asp.net mvc front end or backend? : Asp.Net MVC

0 Answers  


What are the different web pages?

0 Answers  


What tags do you need to add within the asp:datagrid tags to bind columns manually? Give an example.

0 Answers  


Categories