有没有办法限制输入 T 以便能够将默认值添加到函数参数?
public class Identity<T>
{
public readonly T Seed;
public readonly T Increment;
public Identity(T seed = 1, T increment = 1)
{
Seed = seed;
Increment = increment;
}
}
这是T seed = 1
我希望能够做到的,并且可能将 T 限制为非十进制数字类型,如短、整数、长......