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();
            }
    
        }
    

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

  • 相关阅读:
    PHP 超级全局变量
    PHP 魔术变量
    PHP 变量
    Thinkphp 模板中常用的系统变量总结
    PHP $GLOBALS超全局变量分析
    php使用curl的post提交数据和get获取网页数据的方法总结
    php获取客户端真实ip地址的三种方法
    Jquery 【on事件】
    ptyhon【递归练习】
    C#中的线程
  • 原文地址:https://www.cnblogs.com/wwkk/p/9142870.html
Copyright © 2011-2022 走看看