示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("**** Fun with const ****\n");
            Console.WriteLine("PI = {0};", MyMathClass.PI);
            // ОШИБКА!!! Нельзя изменять константу!
            // MyMathClass.PI = 3.1444;
            MyMathClass m = new MyMathClass();

            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("The value of Pi is {0}, can be accessed like a static", MyMathClass.PI);
            //MyMathClass.PI = 22; left hand must be a variable, property or indexer, is a const instead

            LocalConstStringVariablbe();

            MyMathClass mc = new MyMathClass();
            Console.WriteLine("ReadOnly val {0}",  mc.readOnlyVal);

            Console.WriteLine("ReadOnly is not implicitely static. Value of static readonly {0}", MyMathClass.STATIC_RO_PI);
            Console.ReadLine();
        }