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

推荐订阅源

P
Palo Alto Networks Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cyberwarzone
Cyberwarzone
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
Security Latest
Security Latest
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
C
Cisco Blogs
博客园 - 【当耐特】
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
B
Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
The Last Watchdog
The Last Watchdog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
F
Fortinet All Blogs
L
LINUX DO - 热门话题
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
爱范儿
爱范儿
O
OpenAI News
J
Java Code Geeks
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 君

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;
        }