- namespace ConsoleApplication1
- {
- //定义枚举.枚举所使用的类型只能为:sbyte, byte, short, ushort, int, uint, long, ulong
- enum student : sbyte {
- name = 1,
- age = 12,
- sex = -11
- }
- //定义结构
- public struct studentInfo {
- public string name;
- public int age;
- public string sex;
- }
-
- class Program
- {
- static void Main(string[] args)
- {
- //枚举的使用方法开始
- int info = Convert.ToInt16(student.name);
- Console.WriteLine("我的名字叫:{0}", info);
- Console.ReadKey();
-
- //结构的使用方法开始
- studentInfo cngothicInfo = new studentInfo();
- cngothicInfo.name = "cndeath";
- cngothicInfo.age = 23;
- cngothicInfo.sex = "男";
- Console.WriteLine("结构name:{0}", cngothicInfo.name);
- Console.ReadKey();
- }
- }
- }