Random randomClass = new Random();
List<Type> aList = new List<Type> { new A(), new B(), new C() };
int randomInteger = randomClass.Next(3);
Type type = aList[randomInteger];
typeFunc<type>();
static void typeFunc<T>() where T : A
{
Console.WriteLine("This worked");
}
public class A
{
}
public class B : A
{
}
public class C : A
{
}
Random randomClass = new Random();
List<Type> aList = new List<Type> { new A(), new B(), new C() };
int randomInteger = randomClass.Next(3);
Type type = aList[randomInteger];
typeFunc<type>();
static void typeFunc<T>() where T : A
{
Console.WriteLine("This worked");
}
public class A
{
}
public class B : A
{
}
public class C : A
{
}