zoukankan      html  css  js  c++  java
  • C# 对象初始化器 和数组初始化语法

        public class test
        {
            //属性
            public unicode_gb[] m_unicode_gb = new unicode_gb[10];
            public A[] m_A = new A[10];
            public class A
            {
                public int unicode;
                public int gb;
            }
            public struct unicode_gb
            {
                //unsigned short无符号短整型0~65535
                public int unicode;
                public int gb;
            }
    
            public void func()
            {
                //定义字符串数组
                string[] strDoorStatus = { "invalid", "sleep", "Normally open", "Normally close" };
                string[] arrayB = new string[3] { "shirdrn", "Hamtty", "Saxery" };
                string[] arrayC = new string[3];
                arrayC[0] = "Shirdrn";
                arrayC[1] = "Hamtty";
                arrayC[2] = "Saxery";
    
                //对象初始化器
                //T_Sys_UnitTest data = new T_Sys_UnitTest
                //{
                //    Id = Guid.NewGuid().ToString(),
                //    UserId = Guid.NewGuid().ToString(),
                //    Age = 10,
                //    UserName = Guid.NewGuid().ToString()
                //};
    
                m_unicode_gb = new unicode_gb[]
                {
                     new unicode_gb{
                        unicode =0
                    }
                };
    
                var m_A = new A[] {
    
                    new A{
                        unicode =0
                    }
    
                };
    
            }
        }
  • 相关阅读:
    DHCP脚本
    7.31
    7.30
    7.26
    7.24
    VLAN与三层交换机
    静态路由配置
    7.17
    四次挥手
    TCP三次握手,四次挥手
  • 原文地址:https://www.cnblogs.com/enych/p/12449879.html
Copyright © 2011-2022 走看看