namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { Console.WriteLine("Hello, World!"); AppleClass AppleClass = new AppleClass(); AppleClass.Name = "apple"; AppleClass.Ap = "ap"; Fruilt fruilt = (Fruilt)AppleClass; if (fruilt.FruiltType == EnumFruiltType.Apple) { var aa = (AppleClass)fruilt; } } public class Fruilt { public EnumFruiltType FruiltType { get; set; } public string Name { get; set; } } public class AppleClass : Fruilt { public string Ap { get; set; } public AppleClass() { FruiltType = EnumFruiltType.Apple; } } public class OrangeClass : Fruilt { public string or { get; set; } public OrangeClass() { FruiltType = EnumFruiltType.Orange; } } public enum EnumFruiltType { Apple = 0, Orange = 1 } } }
标签:EnumFruiltType,C#,子类,class,AppleClass,set,Fruilt,父类,public From: https://www.cnblogs.com/cxxtreasure/p/18229091