关于静态static

1.静态方法

  

 

using System;

namespace sqlcon
{
    class statictest
    {
        private static void a() {

            Console.WriteLine("123");
        }                
        static void Main()
        {
            statictest.a();
         
            Console.ReadKey();
        }
    }
}
View Code

2.静态类

using System;

namespace sqlcon
{
   static class statictest
    {
      static int q = 123456;//需设置为静态e()函数方法才能访问得到
        private static void a() {
            int a, b, c;
            a = 1; b = 2; c = a + b;
            Console.WriteLine(c);
            Console.WriteLine("123");
        }
        public static void e() {
          a();          
          Console.WriteLine(q);
        }
        static void Main()
        {
           statictest. e();

            Console.ReadKey();
        }
    }
}
View Code

 

  

posted @ 2017-04-16 01:39  ADFL  阅读(118)  评论(0编辑  收藏  举报