C# Extension Method for String Data Type

后端 未结 7 1882
清酒与你
清酒与你 2020-12-11 10:58

My web application deals with strings that need to be converted to numbers a lot - users often put commas, units (like cm, m, g, kg) and currency symbols in these fields so

7条回答
  •  佛祖请我去吃肉
    2020-12-11 12:01

    Please read this article about currency implementations:
    https://docs.microsoft.com/en-us/globalization/locale/currency-formatting

    Example:

    Double myNumber = Double.Parse("$1,250.85", NumberStyles.Any);
    

    PS. You trying parse floating point value to decimal type.

提交回复
热议问题