c# - Generic with T of value type -
is possible define generic class t can belong value type (such int, double , on)?
yes, need struct
constraint:
class onlystructs<t> t : struct { }
but should aware of allows user-defined structs, not int
,double
etc.. unfortunately there no built-in way restrict t
specific types where t : int,double,float
.
Comments
Post a Comment