How to parse a numerical string input to decimal number and convert it back to the string without any loss?
using System;
using System.Globalization;
class Program
{
static void Main(string[] args)
{
string input = "-1.234.567.890,123456789012345678901234567890";
var ci = new CultureInfo("id-ID");
decimal number = decimal.Parse(input, NumberStyles.Number, ci);
string output = number.ToString("N", ci);
Console.WriteLine(output == input);// produces False
}
}
Here I am learning how to parse and convert with the simplest way.