How to restrict T to value types using a constraint?

后端 未结 6 1799
情歌与酒
情歌与酒 2020-12-16 11:46

I want to restrict the possible types N can take-on using a constraint. I wish to restrict N to be either a int or a decimal.

public static Chart PopulateIn         


        
6条回答
  •  离开以前
    2020-12-16 11:59

    The closet you can get is Where T: struct, IComparable, IFormattable, IConvertible. All value types implements these interfaces.

提交回复
热议问题