using System; using System.Globalization; using System.Linq; using System.Collections.Generic; using System.Reflection; public class Test { class Entity { } class Item : Entity { } class Actor : Entity { } public static void Main() { int iterations = 10; Type pType = typeof(Entity); var children = Enumerable.Range(1, iterations) .SelectMany(i => Assembly.GetExecutingAssembly().GetTypes() .Where(t => t.IsClass && pType.IsAssignableFrom(t) && t != pType) .Select(t => t.Name)); var all = string.Join(",", children.ToArray()); Console.Write(all); } }
Standard input is empty
Item,Actor,Item,Actor,Item,Actor,Item,Actor,Item,Actor,Item,Actor,Item,Actor,Item,Actor,Item,Actor,Item,Actor