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
Generic constraints should be more exact, thus we would be able to use operators on generic types.
for example:
public static T Function1(T a,T b) where T:int,long,uint,ulong
{return a/b+a%b;}
The text was updated successfully, but these errors were encountered:
C# is limited by the support for generic constraints offered by the CLR which only really supports class, struct, new(), a subclass and/or a list of interfaces.
Supporting operators would be tricky because operators are both applied to the built-in primitive types, such as the ones you listed, as well as through static methods on any custom type. The IL generated for + could not be the same for System.Int32 v. System.Decimal, but it would have to be.
I want to say that this request is duped (probably multiple times) but I'm having trouble finding an issue number. Perhaps it's still over on CodePlex.
Generic constraints should be more exact, thus we would be able to use operators on generic types.
for example:
public static T Function1(T a,T b) where T:int,long,uint,ulong
{return a/b+a%b;}
The text was updated successfully, but these errors were encountered: