Operator as and generic classes
You need to add where T : class to your method declaration, e.g. T Execute<T>() where T : class { By the way, as a suggestion, that generic wrapper doesn’t really add much value. The caller can write: MyClass c = whatever.Execute() as MyClass; Or if they want to throw on fail: MyClass c = … Read more