using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { /// <summary> /// /// </summary> class Program { /// <summary> /// /// </summary> /// <param name="args"></param> static void Main(string[] args) { Cat cat = new Cat(); cat.name = "Jerry"; cat.color = "Red"; Cat homeCat = new Cat(); homeCat.name = cat.name; homeCat.color = cat.color; homeCat.name = "Tom"; cat.color = "Green"; // readonly const区别? // 枚举类型 ---〉基本类型 Direction dir = Direction.UP; Console.WriteLine((int)dir); // 基本类型 ---〉枚举类型 int underlyingType = 2; Direction enumType =(Direction)Enum.Parse(typeof(Direction), underlyingType.ToString()); // 基本类型 ---〉枚举字符串 int underlyingTypeString = 3; string enumString = Enum.GetName(typeof(Direction), underlyingTypeString); } } /// <summary> /// /// </summary> public class Cat { /// <summary> /// /// </summary> public string name { get; set; } /// <summary> /// /// </summary> public string color { get; set; } } enum Direction { UP, DOWN, LEFT, RIFHT } }