VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > C#编程 >
  • C#教程之C#简单的枚举及结构

本站最新发布   C#从入门到精通
试听地址  
https://www.xin3721.com/eschool/CSharpxin3721/

复制代码
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);
        }
    }
}
复制代码
相关教程