码迷,mamicode.com
首页 > 编程语言 > 详细

C# 对象初始化器 和数组初始化语法

时间:2020-03-09 18:15:52      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:定义   user   new   orm   整型   unsigned   gui   invalid   col   

    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
                }

            };

        }
    }

 

C# 对象初始化器 和数组初始化语法

标签:定义   user   new   orm   整型   unsigned   gui   invalid   col   

原文地址:https://www.cnblogs.com/enych/p/12449879.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!