Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Exploring static methods.Example-1***\n");
            NonStaticClass anObject = new NonStaticClass();

            anObject.NonStaticMethod();//Ok
            //anObject.StaticMethod();//Error
            NonStaticClass.StaticMethod();
            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** 静的メソッドの実装例 その1 ***\n");
            NonStaticClass anObject = new NonStaticClass();

            anObject.NonStaticMethod();
            //anObject.StaticMethod(); //エラー CS0176  インスタンス参照でメンバー 'NonStaticClass.StaticMethod()' にアクセスできません。代わりに型名を使用してください
            NonStaticClass.StaticMethod();
            Console.ReadKey();
        }