Skip to content

How to put dot in decimal number with a label

Israel

Asked Jul 26, 2018, 9:42 AM EDT2 answers
Share
LinkedInX
Hi,
 
I wrote this code to put the number as decimal (for example 125 300 255,00). But I would like to have this number separated like this 125.300.255,00. But its doesnt put dot between number as I want. Please let see my code:
 
C#
double d1, d2, total;
double.TryParse(number1.Text, out d1);
double.TryParse(number2.Text, out d2);
total = d1 - d2;
finalResult.Text = total.ToString("N2"); //Need the final result here please
 
Thank you,
Israel.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi,
     
    I do think in other way and its works.
     
    C#
    double d1, d2, total;
    double.TryParse(number1.Text, out d1);
    double.TryParse(number2.Text, out d2);
    total = d1 - d2;
    finalResult.Text = total.ToString("N2"); //Need the final result here please
    
    
    
    finalResult.Text = string.Format(System.Globalization.CultureInfo.GetCultureInfo("id-ID"), "{0:#,##0.00}", double.Parse(finalResult.Text));
    0
  • Rafnas T P
    0
    hi,
    you can not add more than one decimal point when you convert,
    VB.NET
    if you want to do that, then  you can do as a string, if in a string space is there then replace those spces with decimal point  as per you ex,
    
    string nomber =  "125 300 255,00";
    string dotednomber =  nomber.Replace(" ",".");
    0