using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp35 { internal class Program { static void Main(string[] args) { ParseEnumDemo(); Console.ReadLine(); } static void ParseEnumDemo() { List<string> namesList = new List<string>() { "Science","Technology","Engineering","Mathematics" }; foreach (string name in namesList) { var currentBookEnum=(BookEnum)Enum.Parse(typeof(BookEnum), name); Console.WriteLine($"{currentBookEnum},{(int)currentBookEnum}"); } } public enum BookEnum { Science = 100, Technology = 200, Engineering = 300, Mathematics = 400 } } }
标签:retrieve,name,enum,System,BookEnum,currentBookEnum,using From: https://www.cnblogs.com/Fred1987/p/18202708