what is read only and constant

Answer Posted / xiaof

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;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of tuple in c#?

588


If I have more than one version of one assemblies, then how'll I use old version (how/where to specify version number?)in my application?

593


How can we sort an array in c#?

592


3. Use layered architecture for coding. s.no name description 1 abc xxxxxxxxx 2 abc xxxxxxxxx 3 4 5 6 7 8 Select all Clear all Add Delete Name Description Save close

1536


Could you explain the difference between func vs action vs predicate?

534






what is c# command?

597


What is inheritance c#?

583


Please explain value types and reference types used in c#?

566


Can we inherit abstract class in c#?

588


Which config file has all the supported channels/protocol?

631


What will be the output of the following code?

589


What is inumerable?

638


What are the Configuration files in .net?

590


how to create crystal reports give one detail example(i want to view age category report) please give suitable example in my small knowledge

1716


What is property c#?

592