c# string character replace

前端 未结 4 1775
一向
一向 2021-01-14 18:04

I have a string where the third last character is sometimes a , If this is the case I want to replace it with a . The string could also have other

4条回答
  •  逝去的感伤
    2021-01-14 18:45

    A more proper method would probably be to use the cultures

    string input = "12345,67";
    System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL");
    decimal value = System.Convert.ToDecimal(input);
    System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
    string converted = string.Format("{0:C}", value);
    

提交回复
热议问题