[英](C#) How to find a cell from the axis of a DataTable / Divide a number Into two
您可以尝试以下方法:
// input:
double d = 0.87d;
// convert to integer
int i1 = (int)(d * 100);
// all but the last digit
int i2 = i1 / 10;
// last digit alone
int i3 = i1 - (i2 * 10);
i3
应该是目标单元格的列索引,而i2
是行:
double t = yourDataTable.Rows[i2].Field<double >(i3);
一些注意事项:
不确定(0,0)的含义是-1,但是您始终可以为特殊情况添加if
子句,或者可以修改表内容。
如果您显示的标题实际上是表数据的一部分,那么您当然可以添加一个偏移量。
如果行数超过99,9
,则不应使用100
而应使用更大的10
..
另请注意,看似清晰的小数位数实际上并不存在于二进制数中; 因此, integer
是一种简单的方法,可以避免在floats
或doubles
数中使用计算或通过strings
进行计算时可能导致的复杂性。 但是,可以使用decimal
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.