Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference b/w Readonly Variable and Constant
Variable?

Answer Posted / arun

constants are dealt with at compile-time, while static
readonly fields are set at the time they are evaluated at
run-time.
the constant value will need to be recompiled if the
constant value changes. Libraries referencing a static
readonly field will reference the field and not the value,
thus they will pick up any change in the field without the
need for recompilation
constants will only support value types plus the
special .NET ones string and null while Static readonly
fields are able to hold reference types too.
So, constants should be used when it is very unlikely that
the value will ever change, or if no external apps/libs
will be using the constant. Static readonly fields should
be used when run-time calculation is required, or if
external consumers are a factor

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name a feature which is common to all .net languages?

1009


Explain convert.tostring and i.tostring method?

915


Explain jagged array in vb.net?

984


Explain the difference between value and reference types?

878


Name the tool which can convert visual basic old version to .net compatibility version?

1041


Which class allows an element to be accessed using unique key?

953


What is the difference between static or dynamic assemblies?

1011


Explain the differences between vb.net and c#, related to oops concepts?

934


Can you please explain the difference between dataset and datareader?

1027


What is datatype conversion?

1113


Can you please explain the difference between c# and vb.net?

1051


How a base class method is hidden?

1078


What is a static class?

1004


Explain the use of option explicit?

1001


Which dll is used for microsoft .net run time?

978