Type restrictions

Is there a way to restrict a generic type to only an integral type?

In the example, if I have a method

T[] sort<T>(T[] data) where : T ... {}

what would I set as a limitation if I wanted the parameter to be a kind of integral type?

I tried looking at MSDN , however it does not seem to say anything about constraining and primitive types.

Thank you for your help.

+3
source share
2 answers

Nope. I asked this question before with VB.Net.

Common Classes (T) - An indication from the VB.Net type range

:
, , , . ( ) ( ), : (Of t As {Structure, IComparable}).

+3

- , ( #) struct IComparable, .

, #/.NET?

0

Source: https://habr.com/ru/post/1764117/


All Articles