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
I apologies in advance as I am almost sure this will be a duplicate, but I cannot find it.
Has this been considered? When I have a generic type with, as type constraint, another generic type, I don't want to specify the constraints of the constraint in the main generic as they could easily be inferred:
Nice to have:
class Generic where T : OtherGeneric { }
Instead of:
class Generic<T, TOther> where T : OtherGeneric { }
The text was updated successfully, but these errors were encountered:
I want to say that I've seen a dupe of this as well but I can't find it at the moment.
In my opinion I would prefer that the class signature contain the two generic type arguments because even if the C# compiler could infer that second type parameter the resultant CLR generic type will have an arity of two, Generic2[T, TOther]. I also like the check that the C# compiler would provide in ensuring that any generic type parameters used in the constraint are in scope, so that Generic<T1, TOther> where T : OtherGenericdoesn't accidentally becomeGeneric<T1, TOther, TOtter> where T : OtherGeneric`.
It could also infer it just in the usages and not in the declaration, that would be a good step forward already. (The inference could be implicit and the underlying type could stay as Generic`2[T, TOther].
I apologies in advance as I am almost sure this will be a duplicate, but I cannot find it.
Has this been considered? When I have a generic type with, as type constraint, another generic type, I don't want to specify the constraints of the constraint in the main generic as they could easily be inferred:
Nice to have:
class Generic where T : OtherGeneric { }
Instead of:
class Generic<T, TOther> where T : OtherGeneric { }
The text was updated successfully, but these errors were encountered: