如何运用C#一个小数转化为整数
来源:百度知道 编辑:UC知道 时间:2024/06/01 05:15:13
doule i=100.11;
int index = i.IndexOf(".");
string Z= i.ToString().Substring(0, index));
string L= i.ToString().Substring(index + 1);
Z就是所要得到的整数
double i=100.1;
int j = (int)i;// 舍去小数
int k = Convert.ToInt32(i);// 四舍五入
以上是2个不同的方法。