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

What is difference between view and partial view?

0 Answers  


What was the difference between machine.config and web.config files

17 Answers   Assurgent, NIIT, TCS,


What is the Web.config file used for? a) To store the global information and variable definition for the application. b) Configures the time that the server-side codebehind module is called c) To Configure the Web Server. d) To Configure the Web browser.

8 Answers   HCL, IBM, Syntax Softtech, Vypin, WideVision Technologies,


If we add a textbox and give the required field validator,and i add two radio buttons 1 is yes another one is No.And i add another one server control button ,if i click the button ,if the radio button Yes is checked the validation control is fired ,if no the validation control is not fired.So what you used to solve this problem.

6 Answers   CTS,


Are cookies client side or server side?

0 Answers  






what is diffrence between debug class and trace class in asp.net ?

2 Answers  


differences between class inheritance and interface?

2 Answers  


Is it possible to create web application with both webforms and mvc?

0 Answers  


Define view state.

0 Answers  


diffrance between stored procedure & function in sql server?

2 Answers  


What are the advantages and disadvantages of session?

0 Answers  


What is the Difference B/W Finalize() and Dispose() in .Net?

12 Answers   HCL, IBM,


Categories