欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#简单的枚举及结构

程序员文章站 2024-01-23 19:56:10
using System; namespace program { enum WeekDays { a,//0 b,//1 c = 11,//11 赋值以后就变成11,不赋值就是2 d,//12 e,//13 f,//14 g//15 }//不能输入数字 struct student { publi ......
using system;
namespace program
{
    enum weekdays
    {
        a,//0
        b,//1
        c = 11,//11 赋值以后就变成11,不赋值就是2
        d,//12
        e,//13
        f,//14
        g//15
    }//不能输入数字


    struct student {
        public string name;
        public char sex;
        public int age;
    }
    class program1
    {
        static void main(string[] args)
        {
            weekdays letter;
            letter = weekdays.e;
            for (letter = 0; letter < weekdays.g; letter++)
            {
                console.writeline(letter);//看看枚举里的值到底是多少
            }

            student bruce;//结构体的运用
            bruce.age = 18;
            bruce.name = "布鲁斯";
            bruce.sex = '男';
            student talyo;
            talyo.age = 19;
            talyo.name = "泰勒";
            talyo.sex = '女';
            console.writeline("姓名:{0}",bruce.name);
            console.writeline("年龄:{0}",bruce.age);
            console.writeline("性别:{0}",bruce.sex);
            console.writeline("姓名:{0}",talyo.name);
            console.writeline("年龄:{0}", talyo.age);
            console.writeline("性别:{0}", talyo.sex);
        }
    }
}

C#简单的枚举及结构