惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Know Your Adversary
Know Your Adversary
D
Docker
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
V
V2EX
V
Visual Studio Blog
J
Java Code Geeks
博客园 - 【当耐特】
罗磊的独立博客
量子位
W
WeLiveSecurity
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
O
OpenAI News
PCI Perspectives
PCI Perspectives
The Last Watchdog
The Last Watchdog
S
Schneier on Security
博客园 - Franky
WordPress大学
WordPress大学
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Latest
Security Latest
Cisco Talos Blog
Cisco Talos Blog
腾讯CDC
美团技术团队
博客园 - 叶小钗
www.infosecurity-magazine.com
www.infosecurity-magazine.com
月光博客
月光博客
S
Secure Thoughts
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
TaoSecurity Blog
TaoSecurity Blog
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
D
DataBreaches.Net
Project Zero
Project Zero
S
SegmentFault 最新的问题
C
Cisco Blogs
H
Help Net Security
Google Online Security Blog
Google Online Security Blog
A
About on SuperTechFans
F
Fortinet All Blogs
博客园 - 司徒正美

博客园 - 君

50口诀让你轻松记四六级单词 苦瓜炒蛋 随笔 年旦前 经历一劫 2007-12-16 随缘也 留脚 一篇不错的文章 .net修改网络配置,如IP,DNS等 .net写发送邮件工具 2007-2-3 2006-12-23 .NET中获取系统硬件信息 网站宣传 用C#播放声音文件 DotNetMagic做应用程序界面(类似office2003风格) Grove——.NET中的ORM实现(转载,学习...........)
将货币数字描述转化成中文描述 - 君 - 博客园
· 2008-01-21 · via 博客园 - 君

/// <summary>
        
/// 将货币数字描述转化成中文描述(整数部分控制在12位,小数部分在2位数)
        
/// </summary>
        
/// <param name="str"></param>
        
/// <returns></returns>

        public static string DoNumberCurrencyToChineseCurrency(string str)
        
{
            
if (str.Length < 1)
            
{
                
return string.Empty;
            }

            
//去掉描述货币多余的字符[,]
            str = str.Replace(","string.Empty);
            str 
= str.Replace(""string.Empty);
            str 
= str.Replace(""".");
            str 
= str.Replace("-"string.Empty);
            str 
= str.Replace("+"string.Empty);
            str 
= str.Replace(""string.Empty);

            System.Text.RegularExpressions.Regex reg1 
= new System.Text.RegularExpressions.Regex(@"^[-]?\d+[.]?\d*$");
            
if (!reg1.IsMatch(str))
            
{//参数不是纯数字
                return string.Empty;
            }


            
string[] cstr ="""""""""""""""""""" };
            
string[] wstr ="""""""""""""""""""亿""""""" };

            
while (str.StartsWith("0"))
            
{//去掉字符开头的0
                str = str.Substring(1, str.Length - 1);
            }

            
string strInt = str;//整数部分字符串
            string strDec = string.Empty;//小数部分字符串
            string ReturnDec = string.Empty;//返回的小数部分的中文描述
            int Index = str.IndexOf(".");//查找是否有小数
            if (Index > 0)
            
{//存在小数
                strInt = str.Substring(0, Index);
                strDec 
= str.Substring(Index + 1);
                
string[] fsstr = new string[] """" };
                
for (int a = 0; a < 2; a++)
                
{
                    ReturnDec 
= ReturnDec + cstr[int.Parse(strDec[a].ToString())] + fsstr[a];
                }

            }

            
//计算整数部分
            int len = strInt.Length;
            
int i;
            
string tmpstr, rstr;
            rstr 
= "";
            
for (i = 1; i <= len; i++)
            
{
                tmpstr 
= strInt.Substring(len - i, 1);
                rstr 
= string.Concat(cstr[Int32.Parse(tmpstr)] + wstr[i], rstr);
            }

            rstr 
= rstr.Replace("拾零""");
            rstr 
= rstr.Replace("零拾""");
            rstr 
= rstr.Replace("零佰""");
            rstr 
= rstr.Replace("零仟""");
            rstr 
= rstr.Replace("零万""");
            
for (i = 1; i <= 6; i++)
                rstr 
= rstr.Replace("零零""");
            rstr 
= rstr.Replace("零万""");
            rstr 
= rstr.Replace("零亿""亿");
            rstr 
= rstr.Replace("零零""");
            rstr 
+= "";

            
if (ReturnDec.Length > 0)
            
{//存在小数
                rstr = rstr + ReturnDec;
            }

            
else
            
{
                rstr 
+= "";
            }

            
return rstr;
        }