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); } } }