首页 > 其他 > 详细

Chapter 7. 结构体、枚举

时间:2016-05-14 16:46:02      阅读:211      评论:0      收藏:0      [点我收藏+]
//结构体:定义一组变量
        struct student
        {
            public int number;
            public string name;
            public string sex;
            public one xx;
            
        }
        struct one
        {
            public string aa;
            public int bb;
        }

        //枚举类型:定义一个常量
        enum meiju
        {
            one = 3, //不是赋值,是指向索引,3号索引是one
            two = 6, //6号索引是two这个常量
            three,
            four = two  //逗号可以省略,若一个常量等于之前的一个常量,那么就等于这个常量
        }
        enum meiju1
        {
            one = 3,
            two = 6,
            three,
            four = three
        }


        static void Main(string[] args)
        {
            //初始化结构体
            student stu = new student();
            stu.number = 1;
            stu.name = "张三";
            stu.sex = "";
            student stu1 = new student();
            stu1.number = 2;
            stu1.name = "李四";
            stu1.sex = "";
            Console.ReadLine();

            student stu2 = new student();
            stu2.xx.aa = "123";
            stu2.xx.bb = 123;
            Console.ReadLine();

            Console.WriteLine(meiju.one);
            Console.WriteLine(meiju1.four);
            Console.ReadLine();

            

        }

 

Chapter 7. 结构体、枚举

原文:http://www.cnblogs.com/xiao55/p/5492778.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!