public static void Main()
var cls = new SomeClass<Lion>();
cls.SomeMethod<Animal>(new Lion());
public class SomeClass<T1>
public void SomeMethod<T2>(T1 someParameter) where T2 : class
if(!(someParameter is T2 t2))
throw new Exception("Invalid type");
Console.WriteLine($"Hello from {t2}");
public class Lion : Animal{}