c# - 如何在 c# 中使用 datatable.compute 进行除法?
问题描述
我在 C# 中使用 divion 运算符,如下所示,并得到一个错误,比如Specified cast is not valid
它背后的任何原因
DataTable dt = new DataTable();
int answer = (int)dt.Compute("(1*4000*700*20)/4000", "");
解决方案
使用Convert()
而不是强制转换来获得int
结果
int answer = Convert.ToInt32(new DataTable().Compute("(1*4000*700*20)/4000", ""));
推荐阅读
- amazon-s3 - 分段上传期间“找不到一个或多个指定的部分”
- class - 如何在 Arduino 应用程序中构建我自己的类库?
- python - 使用 tf.saved_model 保存和加载模型时会发生什么变化
- php - 表单标签仅针对第一条消息从边界打印出来
- javascript - 如何在 NodeJS 中访问当前 URL
- javascript - 仅在异步函数执行后执行函数
- python - ValueError:检查目标时出错:预期 PREDICTIONS 有 4 个维度,但得到的数组形状为 (20, 131) [Keras]
- android - 使用 ConstraintLayout 的片段 onCreateView 不遵守 ConstraintSet
- reactjs - 单击时如何将数据从一个反应组件传递到另一个反应组件
单击时如何将数据从一个反应组件传递到另一个反应组件
[ { "id": 1, "title": "XYZ Title", "body": "www.xyz.com sample hits", "comments": [ { "id": 1, "postId": 1, "name": null,
- java - 如何从 Java 中的用户输入中获取日期?