What is the Difference between read only and constant
variables?
Answer Posted / bharathi
Constants:
constant is used for declaring variable as constant and this constant value cannot be modified once after declartration.
It is must to declare the constant value at the time of declaration only.
Example:
constant int y=5;
Readonly
Readonly variables can not be modified like constant,but it is after initialization.
So.it is not mandatory to initialize those variables at declaration time.they can also be initialize after declaration.
Example:
readonly int x;
add()
{
x=5;
}
Both after initilization, we can not modify those values again.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is out in c#?
What is int parse in c#?
What is the wildcard character in sql?
Explain static class members.
What's your approach to fetch static data in your windows form application?
Can properties be private in c#?
Assembly Code. in Rejester AL. How do Contast Replece( or Change): Bit D3 With Bit D4 and Bit D2 With Bit D5 and Bit D1 With Bit D6 and Bit D0 With Bit D7 I am Not Know Very Well Write English.
Name the control which cannot be placed in mdi?
Explain about multithreading?
What kind of the information stored inside the assembly?
what are the contents of an assembly ?
What does an indexer do?
What is remote data?
Define Final Class in C#
What is the difference between finalize() and dispose()?