zoukankan      html  css  js  c++  java
  • 类初始化成员加载测试

    
     public class SS
        {
            public static int ss = getNum();
    
            public static int age = 23;
    
            private static int getNum()
            {
                return age;
            }
        }
    
    
      public class KK
        {
            public KK()
            {
                Console.WriteLine("55555");
                wsd = 66666;
            }
    
            private static string fds = null;
    
            public static string FDS
            {
                get
                {
                    return fds = MSS.Dof();
                }
            }
    
            public int wsd;
            public static int ddddddds()
            {
                Console.WriteLine("1111111");
                return 77777;
            }
        }
    
    
    
     public class MSS
        {
            public static int dd = KK.ddddddds();
    
            public static string Dof()
            {
                Console.WriteLine("33333");
                return "444444";
            }
    
        }
    
    
    
    class Program
        {
            static void Main(string[] args)
            {
                Test();
    
                Console.Read();
            }
    
            public static void Test()
            {
                Console.WriteLine("222222");
                Console.WriteLine(KK.FDS);
                Console.WriteLine(new KK().wsd);
                Console.WriteLine(MSS.dd);
    
    
                Console.WriteLine(SS.ss);
    
                //Console.WriteLine("33333");
                //int kkk = KK.fds;
                //int hhh = new KK().wsd;
                //int ppp = MSS.dd;
                //Console.WriteLine(kkk);
                //Console.WriteLine(hhh);
                //Console.WriteLine(ppp);
            }
        }
    

    这是第一个

    
      public class FOO
        {
         ②   //static FOO()
            //{
            //}
    
    
    
            public static string x3 = GetString3("11111");
    
            public static string GetString3(string s)
            {
                Console.WriteLine(s);
                return s;
            }
    
    
            public static string x = GetString("22222");
    
            public static string GetString(string s)
            {
                Console.WriteLine(s);
                return s;
            }
            public static string x2 = GetString2("33333");
    
            public static string GetString2(string s)
            {
                Console.WriteLine(s);
                return s;
            }
    
        }
    
    
     public class dsds
        {
            static void Main(string[] args)
            {
                Console.WriteLine("44444");
                FOO.GetString("5555555");
    
              ①  string field = FOO.x;
                Console.Read();
            }
    
        }
    

    把①和②分别注释和放开 输出的差别

  • 相关阅读:
    git把dev部分提交过的内容合并到master
    shell命令修改文件内容
    js时间格式化
    js判断对象是否为空
    JS数组遍历方法
    批量修改文件后缀
    curl实现put请求
    lumen伪静态路由设置示例
    nginx client_body_buffer_size
    nginx模块开发
  • 原文地址:https://www.cnblogs.com/wwkk/p/9142870.html
Copyright © 2011-2022 走看看