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
Explain i.tostring method?
Explain convert.tostring and i.tostring method?
How to run a dos command in vb.net?
Sir, what code to store data from vb net sql server 2008 to 2005 and at the same time in order to validate the data entered is not the same, but there have been contacts in the module. Examples such as the log table that I created, the user name as the primary key.
What are the differences between server-side and client-side code?
Explain about visual basic.net?
Explain private assembly?
What is strong typing and weak typing?
Explain some of the exclusive features which are present in vb?
Can you please explain the difference between thread and process?
Can you please explain the difference between int and int32?
What is the differences between dataset.clone and dataset.copy?
What is an application domain? how they get created?
What is a static variable?
Why is the xml infoset specification different from the xml dom?