As in C #, for a generic method, set the restriction to an integer type only (byte, sbyte, short, ushort, int, uint, long, ulong)
public T example<T>(this T value) where T (...)???? As in C #, for a generic method, set the restriction to an integer type only (byte, sbyte, short, ushort, int, uint, long, ulong)
public T example<T>(this T value) where T (...)???? No As constraints for generalizations only the following constructions can be used:
As workarounds, you can use the following options:
T parameter without restrictions and check the type at the beginning of the method (this is, for obvious reasons, a “weaker” solution)Source: https://ru.stackoverflow.com/questions/583642/
All Articles