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 have a web application running without web.config file?

0 Answers  


What is simple data binding?

0 Answers  


I am trying to implement sorting facility from client side code in GridView Control. So how can I fill up an Array inside client side code (using JavaScript), i want to assign my DataSet object declared and filled up on Server side(in code behind) to the array (on client side)

0 Answers   HCL,


What is X-Path?

2 Answers   Sherston,


When we use cookie less session? Explain its working?

0 Answers   Sans Pareil IT Services,


when user is logged on the information is saved in a cookie, what is the name of that cookie?

5 Answers   Mind Tree,


Where are session variables stored?

0 Answers  


How can we read a columnised text data in ASP.Net C#? Columnised means my data is stored in a text file and I have numeric data or string data in this file. For ex. If I am searching for the data of gender and I know that gender data is stored at column 32 in text file. How can I get this data in ASP.Net page. Thanks for help in advance.

2 Answers  


What is cas?

0 Answers  


Name the method that needs to be invoked on the dataadapter control to fill the generated dataset with data?

0 Answers  


where the stored procedure are written in business logic or data acess layer?

2 Answers  


what is SAP fullform

161 Answers   A3Logics, Amazon, DFD, Federal Mogul, Hol Info, IBM, Infosys, Jai Ganesh, Kesri Metal, Lupin, Microsoft, RPG, SAP Labs, SRS Group, TCS, Videocon,


Categories