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

Popular posts from this blog

java - How to print docx and pdf? -

qml - Is it possible to implement SystemTrayIcon functionality in Qt Quick application -

java - IntelliJ to move a class along with conflicted classes to a new package? -