格式化数字 - 括号中的负数 [英] Formatting numbers - Negative numbers in bracket

查看:120
本文介绍了格式化数字 - 括号中的负数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个能转换的功能: -

1)($ 1.25)至-1.25

2)$ 1.25至1.25

待办事项进一步的基本数学计算比如Addition。



我尝试过使用System.Text.RegularExpressions.Regex()和System.String .Format(),但没有运气。请帮助。

I need a function which converts:-
1) ($1.25) to -1.25
2) $1.25 to 1.25
To do further basic mathematical calculation. like Addition.

I have tried using System.Text.RegularExpressions.Regex() and System.String .Format(),but no luck.Please help.

推荐答案

1.25)到-1.25

2)
1.25) to -1.25
2)


1.25到1.25

进一步进行基本的数学计算。比如Addition。



我尝试过使用System.Text.RegularExpressions.Regex()和System.String .Format(),但没有运气。请帮助。
1.25 to 1.25
To do further basic mathematical calculation. like Addition.

I have tried using System.Text.RegularExpressions.Regex() and System.String .Format(),but no luck.Please help.


您是否已尝试使用 Decimal.Parse方法(String,NumberStyles) [ ^ ]



此方法允许您定义不同的标志如何解释输入字符串。



例如我的语言环境以下转换正确:

Have you already tried using Decimal.Parse Method (String, NumberStyles)[^]

This method lets you to define different flags how to interpret the input string.

For example with my locale the following converts corrrectly:
decimal.Parse("(€1,25)", System.Globalization.NumberStyles.Currency);



货币标识符和小数点符号通过区域设置信息控制。


The currency identifier and the decimal point symbol are controlled via locale information.


这篇关于格式化数字 - 括号中的负数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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