【发布时间】:2015-07-31 08:40:19
【问题描述】:
我正在使用 DataTable 类的 Compute 方法来评估和表达。 当值为整数时,评估有效,当表达式为十进制值时,评估失败。我收到“System.FormatException”异常。
这里是示例代码:
var dt = new DataTable();
var passingResult = dt.Compute("CONVERT('100', 'System.Decimal') > 3", null); //works
var failingResult = dt.Compute("CONVERT('100.1', 'System.Decimal') > 3", null); //fails
【问题讨论】:
-
如果我运行代码,两者都可以正常工作
-
两者都必须正常工作....!!
-
由于某种原因,当我有单引号时,它在我这边失败了。我删除了数字周围的引号,现在它可以工作了。
标签: c# datatables evaluation