Give an example code below, can someone explain why the first typeof() call works successfully and the second one fails? It doesn't matter if they are classes or interfaces that it fails anyway.
typeof()
interface ITestOne<T1> { T1 MyMethod(); } interface ITestMany<T1, T2> { T1 MyMethod(T2 myParameter); } void Main() { var typeOne = typeof(ITestOne<>); //This line works var typeTwo = typeof(ITestMany<>); //Compile error }
You need to tell the compiler that you are looking for a generic type with two generic arguments. Add a comma between the angle brackets:
var typeTwo = typeof(ITestMany<,>);