C# Currency to string

后端 未结 10 2817
旧巷少年郎
旧巷少年郎 2021-02-19 10:52

I am querying a database field that returns a money value, I am assigning this to a string but it is adding extra 00 on the end.

e.g. Query returns 30.00

10条回答
  •  太阳男子
    2021-02-19 11:35

    I'd use something like

    string value = ReturnValue.ToString("0.00");
    

    This uses the ToString overload that accepts a format string. The above format string "0.00" specifies two decimal places.

提交回复
热议问题