本文介绍了如何添加大括号“("和“)";并删除负号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个负数,我想删除负号并将括号放在数字的第一个和最后一个
例如:
-556445.90到(556445.90)像这样.
Hi
I have a negative numbers for that i want to remove the negative sign and add braces to first and last of the numbers
for eg:
-556445.90 to (556445.90) like this.
推荐答案
int neg = -16;
int pos = 16;
Console.WriteLine(neg.ToString("##;(##)"));
Console.WriteLine(pos.ToString("##;(##)"));
将打印
(16)
16
decimal d = -556445.90m;
string s = d < 0 ? "(" + (-d).ToString() + ")" : d.ToString();
干杯
Andi
Cheers
Andi
decimal d = -556445.90;
string s = (d*-1).ToString("(f)");
Standard Numeric Format Strings[^]
这篇关于如何添加大括号“("和“)";并删除负号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!