Mega Code Archive

 
Categories / C# Tutorial / LINQ
 

Use a LINQ query to find the public enums

using System; using System.Reflection; using System.IO; using System.Linq;   public class MainClass   {     static void Main(string[] args)     {       string displayName = null;       displayName = "System.Windows.Forms,Version=2.0.0.0,PublicKeyToken=b77a5c561934e089,Culture=\"\"";       Assembly a = Assembly.Load(displayName);       Type[] types = a.GetTypes();       var publicEnums = from pe in types where pe.IsEnum && pe.IsPublic select pe;       foreach (var pe in publicEnums)       {         Console.WriteLine(pe);       }     }   }