<p>Can anyone tell me if there is a way with generics to limit a generic type argument <code>T</code> to only:</p>

<ul>
<li><code>Int16</code></li>
<li><code>Int32</code></li>
<li><code>Int64</code></li>
<li><code>UInt16</code></li>
<li><code>UInt32</code></li>
<li><code>UInt64</code></li>
</ul>

<p>I'm aware of the <code>where</code> keyword, but can't find an interface for <strong>only</strong> these types,</p>

<p>Something like:</p>

<pre><code>static bool IntegerFunction&lt;T&gt;(T value) where T : INumeric 
</code></pre>

There's no constraint for this. It's a real issue for anyone wanting to use generics for numeric calculations.
I'd go further and say we need
```
```
static bool GenericFunction<T>(T value) 
    where T : operators( +, -, /, * )
```
```
Or even
```
```
static bool GenericFunction<T>(T value) 
    where T : Add, Subtract
```
```
Unfortunately you only have interfaces, base classes and the keywords
```
struct
```
(must be value-type),
```
class
```
(must be reference type) and
```
new()
```
(must have default constructor)
You could wrap the number in something else (similar to
```
INullable<T>
```
) like
here on codeproject
.
You could apply the restriction at runtime (by reflecting for the operators or checking for types) but that does lose the advantage of having the generic in the first place.