What is the difference between readonly and const

Answer Posted / porchelvi.a

Constant:
--------
we have to initialize at the declaration itself
we could not change the value of constant variable.

Read only:
----------
we can not initialize the Read only variable during
declaration.we can initialize it in constructor only.after
that we could not change the value.Read noly is instance
based variable.

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

why delegate is type safe?

2603


What is equal c#?

510


What is dbml file in c#?

540


Explain the difference between object type and dynamic type variables in c#?

499


How much time will it take to learn unity?

475






What exception can an overridden method throw in comparison with the method it is overriding?

465


What is threading in c# with example?

461


Is a decimal an integer?

478


What is toint32 c#?

622


How does c# generics and c++ templates compare?

472


Any problem found in vs.et

587


What is the namespace for datatable in c#?

500


Are string objects mutable or immutable?

531


What is static and use of it?

473


What is difference between dynamic and var in c#?

484