简体   繁体   English

如何将小数点后的数字添加到数字

[英]How to add number after decimal to the number

I want to take a number with a decimal point and add the numbers after the point to the integer number.我想取一个带小数点的数字,把小数点后面的数字加到 integer 这个数字上。

For example:例如:

input: 1.88输入: 1.88

Output: 188 Output: 188

Not specifically working with 2 decimal numbers不专门使用 2 个十进制数

Thanks.谢谢。

As suggested by kosist:正如科斯特所建议的:

double input = 1.88;
var inputAsString = input.ToString(CultureInfo.InvariantCulture);
var output = inputAsString.Replace(".", "");
//Optional:
var outputAsInt = int.Parse(output);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM