using System.Collections.Generic;
using System.Runtime.CompilerServices;
class Subclass<TSubclass, T>
Values = new List<Subclass<TSubclass, T>>();
if (typeof(TSubclass).IsSealed)
RuntimeHelpers.RunClassConstructor(typeof(TSubclass).TypeHandle);
var allDerivedClasses = from assembly in AppDomain.CurrentDomain.GetAssemblies()
where !assembly.IsDynamic && assembly.FullName.StartsWith("OurNamespace.")
from assemblyType in assembly.GetExportedTypes()
where assemblyType.IsClass && !assemblyType.IsAbstract && typeof(TSubclass).IsAssignableFrom(assemblyType)
foreach (var derivedType in allDerivedClasses)
RuntimeHelpers.RunClassConstructor(derivedType.TypeHandle);
if (!Values.Any(i => i.Value.Equals(this.Value)))
public T Value { get; set; }
public static List<Subclass<TSubclass, T>> Values { get; private set; }
class Superclass : Subclass<Superclass, int>
public static Superclass SuperclassA1 = new Superclass { Value = 1 };
public static Superclass SuperclassA2 = new Superclass { Value = 2 };
public static Superclass SuperclassA3 = new Superclass { Value = 3 };
public static Superclass SuperclassA4 = new Superclass { Value = 4 };
public static Superclass SuperclassA5 = new SuperClassCustom { Value = 5 };
class SuperClassCustom : Superclass
public static void Main()
foreach (var value in Superclass.Values)
Console.WriteLine(value.Value);