What is read only and its example

A read only member is like a constant in that it represents an unchanging value. The difference is that a readonly member can be initialized at runtime, in a constructor as well being able to be initialized as they are declared. For example

public class MyClass

{

public readonly double PI = 3.14159;

}

Because a readonly field can be initialized either at the declaration or in a constructor, readonly fields can have different

values depending on the constructor used. A readonly field can also be used for runtime constants as in the following example

public static readonly uint l1 = (uint)DateTime.Now.Ticks;