我有以下方法与泛型类型:
T GetValue<T>();
我想将T限制为原始类型,如int,string,float,但不是类类型.我知道我可以像这样为类类定义泛型:
C GetObject<C>() where C: class;
我不确定原始类型是否可能以及如果可能.
.net c# generics type-constraints
.net ×1
c# ×1
generics ×1
type-constraints ×1