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
How to run a dos command in vb.net?
write a program to develop a graphic user interface application of marks book with students names and their names.the program should show the following options main menu,add student details,display student details,maximum mark and minimum mark.
Explain option strict?
Explain the difference between c# and vb.net?
what is interface and when it is used?
What is the difference between datagrid and gridview?
What’s the difference between private and shared assembly?
What is visual basic.net culture?
Name a feature which is common to all .net languages?
Explain about the feature anonymous type?
Can you please explain the difference between dispose and finalize()?
How to execute VB.NET PROJECTS,VB6.0 PROJECTS AND write their test cases.Need Reply Urgently
How to store images in sql server database through vb.net?
What is the main purpose of garbage collector?
What are the advantages of migrating to vb.net?