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

复制代码
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);
        }
    }
}
复制代码

相关教程