Read Only fields (readonly)

  • 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;

    }

    }

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger