我正在尝试在要建立的流利测试框架中使用的数字类型上编写扩展方法。基本上,我想这样做:
public static ShouldBeGreaterThan<T>(this T actual, T expected, string message)
where T : int || T: double || etc...
只是where T : struct不做,因为这也将匹配string和bool,可能还有我忘记的其他事情。我可以做些什么来只匹配数字类型吗?(特别是实现>and <运算符的类型,因此我可以将它们进行比较...如果这意味着我也要匹配日期,则没关系-扩展名仍会按照我的期望进行。)
忽然笑
相关分类