需要转换的双精度或十进制字符串 [英] Need to convert double or decimal to string

查看:112
本文介绍了需要转换的双精度或十进制字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要转换的双串与点分隔的两个数字 我担心的是点,必须始终作为分隔符。

I need to convert double to string with two decimal digits separated with 'dot' My concern is that dot must be always used as separator.

推荐答案

最简单的方法是指定 CultureInfo.InvariantCulture 的文化,如:

The simplest way is to specify CultureInfo.InvariantCulture as the culture, e.g.

string text = d.ToString("N2", CultureInfo.InvariantCulture);

这篇关于需要转换的双精度或十进制字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆