user14064280
user14064280

Reputation:

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.

For example:

input: 1.88

Output: 188

Not specifically working with 2 decimal numbers

Thanks.

Upvotes: 1

Views: 157

Answers (1)

Carra
Carra

Reputation: 17964

As suggested by kosist:

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

Upvotes: 2

Related Questions