You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Tester<T>
where T : class, new()
{
[MyAttribute]
public void Test()
{
Console.WriteLine("abc");
}
}
Calling
var t = new Tester<SomeClass>();
t.Test();
Gives the exception:
System.TypeLoadException: 'GenericArguments[0], 'T', on 'Tester.Tester`1[T]' violates the constraint of type parameter 'T'.'
Issue only happens with class/new() constraints and only at class level.
Method level constraints of this nature work fine.
Interface constraints at class level work fine.
The text was updated successfully, but these errors were encountered:
Calling
Gives the exception:
System.TypeLoadException: 'GenericArguments[0], 'T', on 'Tester.Tester`1[T]' violates the constraint of type parameter 'T'.'
Issue only happens with class/new() constraints and only at class level.
Method level constraints of this nature work fine.
Interface constraints at class level work fine.
The text was updated successfully, but these errors were encountered: