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

推荐订阅源

V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
The Last Watchdog
The Last Watchdog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Secure Thoughts
Hacker News - Newest:
Hacker News - Newest: "LLM"
WordPress大学
WordPress大学
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
TaoSecurity Blog
TaoSecurity Blog
博客园 - Franky
有赞技术团队
有赞技术团队
Google Online Security Blog
Google Online Security Blog
罗磊的独立博客
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
NISL@THU
NISL@THU
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Commits to openclaw:main
Recent Commits to openclaw:main
K
Kaspersky official blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
W
WeLiveSecurity
SecWiki News
SecWiki News
Google DeepMind News
Google DeepMind News
O
OpenAI News
V
V2EX
AI
AI
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
美团技术团队
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园 - 三生石上(FineUI控件)
G
GRAHAM CLULEY
月光博客
月光博客
T
Threatpost
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
Last Week in AI
Last Week in AI
爱范儿
爱范儿
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cloudbric
Cloudbric
酷 壳 – CoolShell
酷 壳 – CoolShell
The Hacker News
The Hacker News
N
News | PayPal Newsroom
Know Your Adversary
Know Your Adversary

博客园 - 置身珠海,学习与奋斗

【转】WPF获取路径解读 善用Wink,将电脑操作录屏为flash (更新图片) [转]ClickOnce部署出现 系统必备的安装位置未设置为组件供应商的网站,无法在磁盘上找到 dotNetFx40LP_Client_x86_x64cs.exe 问题的解决方案 D60 单反相机拍照后,反光板无法正常弹回,报错的解决办法。 关于ListBox绑定到自定义对象 VS 全部补丁包(20100730) 和谐UAC与应用程序配置,抛砖引玉,希望完美解决问题。 论企业信息化的三个阶段:技,术,道 关于ClickOnce在企业内部的应用 中国式管理 Virtual PC 2007 虚拟网络配置 红旗飘扬 关于 Winform 下 ReportViewer 打印异常 中国人成功十要 有没有朋友做过动态表结构的,请教一下 自定义app_offline.htm,让网站升级提示更专业 使用PPC的朋友慎用 星空极速3.2.070416_GD 关于89S51单片机数码管显示的小工具 重新启动IIS的小工具
咱也写个小写数字转大写金额 ,纯粹字符串操作实现
置身珠海,学习与奋斗 · 2007-11-07 · via 博客园 - 置身珠海,学习与奋斗

纯粹字符串操作实现

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    
class Program
    
{
        
static void Main(string[] args)
        
{

            Console.Write(
"输入任意数字,回车转换");
            Console.Write(
"\r\n");
            Console.Write(
"直接回车则退出");
            Console.Write(
"\r\n");

            
for (; ; )
            
{
                
string tmpString = Console.ReadLine();

                
if (tmpString.Trim() == string.Empty)
                
{
                    
break;
                }

                
try
                
{
                    Console.Write(
string.Format("{0} \r\n", ConvertNumberToChineseNumber(tmpString)));
                }

                
catch (Exception ex)
                
{
                    Console.Write(ex.Message);
                }

            }


        }



        
/// <summary>
        
/// 数字转大写金额
        
/// </summary>
        
/// <param name="targetString">数字</param>
        
/// <returns>大写金额</returns>

        private static string ConvertNumberToChineseNumber(string targetString)
        
{
            
string rtnValue = string.Empty;

            
double tmpValue = 0;

            
if (double.TryParse(targetString, out tmpValue))
            
{
                rtnValue 
= tmpValue.ToString("#千兆#百兆#拾兆#兆#仟亿#百亿#拾亿#亿#千万#百万#拾万#万#仟#佰#拾#元.#角#分");
            }

            
else
            
{
                
throw new Exception("输入的不是数字或者过超出范围!");
            }


            
//去个头
            int firstNumberIndex = rtnValue.IndexOfAny(new char[] '0''1''2''3''4''5''6''7''8''9' });

            
if (firstNumberIndex >= 0)
            
{
                rtnValue 
= rtnValue.Substring(firstNumberIndex);
            }



            
//去小数点或去个尾
            int lastNumberIndex = rtnValue.LastIndexOfAny(new char[] '0''1''2''3''4''5''6''7''8''9' });

            rtnValue 
= rtnValue.Substring(0, lastNumberIndex + 2);

            
//小写大写切换

            rtnValue 
= rtnValue.Replace(".""");
            rtnValue 
= rtnValue.Replace("0""");
            rtnValue 
= rtnValue.Replace("1""");
            rtnValue 
= rtnValue.Replace("2""");
            rtnValue 
= rtnValue.Replace("3""");
            rtnValue 
= rtnValue.Replace("4""");
            rtnValue 
= rtnValue.Replace("5""");
            rtnValue 
= rtnValue.Replace("6""");
            rtnValue 
= rtnValue.Replace("7""");
            rtnValue 
= rtnValue.Replace("8""");
            rtnValue 
= rtnValue.Replace("9""");

            
return rtnValue;
        }

    }

}