what is the main differnce between const,readonly and static

Answer Posted / raja

1. we can initialize constant variable only at the
declaration where as readonly varaiable can be initialized
at either declaration or in constructor.

2. we can't use static modifier for the const variable
where as readonly variable can be declared as static

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you prevent a class from being instantiated?

754


What is callback delegate in c#?

615


Can you call from an inherited constructor to a specific base constructor if both base class and an inheriting class has a number of overloaded constructors?

696


What is args c#?

699


What is msil, and why should developers need an appreciation of it if at all?

787






How is exception handling implemented in c#?

756


Can constructor have return type c#?

800


How to sort an int array in c#?

710


Why do we need events in c#?

704


How to find type of variable?

729


How many constructor can a class have?

663


Can you describe iuknown interface in short?

835


Explain About stateless and state full web service

732


How do you name a variable in c#?

680


Why References are stored on heap and variables on stack?

686