What's the difference between const and readonly ?
Answers were Sorted based on User's Feedback
Answer / kirti
You can initialize readonly variables to some runtime values. Let's say your program uses current date and time as one of the values that won't change. This way you declare public readonly string DateT = new DateTime().ToString().
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mr vinod kumar
The readonly keyword is different from the const keyword. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks;
What does a character do ?
On most systems, produces a rather annoying beep.
| Is This Answer Correct ? | 0 Yes | 0 No |
How do I change the permission set for a code group
How can we determine action invoked from HTTP GET or HTTP POST?
how do you truncate a table using entity data model?
The order of the filters that get executed, if the multiple filters are implemented?
What is model first? : Entity framework
What are Scaffold templates in ASP.Net MVC?
Difference between int and int32
What is the difference between structures and enumeration ?
What are the properties of Thread class?
what is mean by versioning? Please answer me. Advance thanks.
what is client wins and store wins mode in entity framework concurrency?
What does 'managed' mean in the .NET context