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 |
What are the new enhancements done in default project template of asp.net mvc 4?
what is more complex to implement property, methods or event? how can I define criteria to compare the difficulty of implementation between them? for example the number of methods wanted to implements property is 2 methods. how many methods I need it to implements events?
What are delegates?where are they used
i just want to write an exam regarding .net?plz give me information about taking a test?where to pay 4 d exam,exam centre?
Is .net core faster than .net framework?
Do you know about the new features in ASP.Net MVC 4 ?
How to Insert a TextBox value in to Sql database using C#.Net coding
Is .NET a runtime service or a development platform?
Explain peek method in tempdata in asp.net mvc?
Does .NET Framework support SAX?
What is .net framework in simple terms?
How large is the .net framework 3.0?