- Read only fields are constants.
- A Read only field can't be modified once initialize.
- Read only fields are declared using the readonly keyword.
- They are initializing in its declaration or in a constructor.
E.g.: public class Test
{
public static readonly double dNum = Math.Sin (Math.PI);
public readonly string sStrOne;
public Test (string sStr)
{
sStrOne = sStr;
}
}
Read Only fields (readonly)
Subscribe to:
Post Comments
(
Atom
)
0 comments :
Post a Comment