what is difference between const, static and readonly?

Answer Posted / amit manekar

The difference is that static read-only can be modified by
the containing class, but const can never be modified and
must be initialized to a compile time constant. To expand on
the static read-only case a bit, the containing class can
only modify it:

in the variable declaration (through a variable initializer).

in the static constructor (instance constructors if it's not
static).

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is base class of .net?

639


What is a web farm?

672


What is the benefit of WebAPI over WCF?

664


How can we identify that the page is post back in asp net?

594


How we implement the multiple paypal value with gridview in my website and how we make a payment through Credit Card.

1520






What is virtual directory in asp.net?

621


Describe paging in asp.net?

762


Explain the difference between inline and code behind - which is best in?

590


Explain the namespace classes used in asp.net mvc? : asp.net mvc

583


How do I open an ashx file in windows 7?

661


How many types of cookies are there in asp.net?

622


how can create login from create and written conde in asp.net

1862


About CLR, reflection and assemblies?

1636


Write a code for sending an email from asp.net application.

641


what is command line compiler.what are the steps and how it is related to debugging.

1498