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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 月异星邪

Anaconda官方网站下载慢的解决方法 定时任务调度自动提醒企业微信 天高云淡 leobbs皮肤 - 月异星邪 - 博客园 仿QQ信息弹出 - 月异星邪 - 博客园 http://www.xywq.com/files/ganzhi11.htm IIS6 Http压缩配置方法 - 月异星邪 IIS6,SESSION超时时间过短的解决(未测试) 如何实现函数IF的嵌套超过七层? 常用asp.net代码 - 月异星邪 - 博客园 在ASP.NET中使用Session常见问题集锦 ASP.NET 2.0:使用用户控件和定制的Web部件个人化你的门户网站 - 月异星邪 ASP.NET中常用的文件上传下载方法 - 月异星邪 Infragistics中WebGrid的MultiColumn Headers设计 轻松实现UltraWebGrid中的分页控制 http://www.bo-blog.com/index.php?l=zh_tw&mod=skins - 月异星邪 ASP.NET中常用的文件上传下载方法 ASP.NET 2.0中使用webpart系列控件 - 月异星邪 ASP.NET2.0 WebPart实例教程 用ASP.NET 2.0实现AJAX风格的Web开发
数字转换为大写人民币(附源码)
月异星邪 · 2007-01-02 · via 博客园 - 月异星邪

【咳咳】注意了,这个也是一道笔试题.今天新安装了VS2005,拿它开刀,竟然发现不是想像中那么简单.
【分析】
①用if...else.........是编程的吗?你
②用swtch,我当初就这些写的,常规方法,结果笔试失败!!
③刚刚想到的,用枚举+for
④................还没想到,期待你的发散思维
【思路】
枚举类型学编程的都学过,但感觉不是很常用,以至于我们都忽略了它的存在,今天终于轮到它表现了.
用两个枚举类型,把1,2,3转化为壹,贰,叁     另一个存放{圆,拾,佰.....}
通过for语句判断具体的单位
【处理的问题及总结】
①定义枚举类(下个帖子具体分析一下其中的一个Bug)
②字符串相连  【+=】  具体是怎么连?
string s="AX"; 
    s+="zhz";     //等价于   s=s+"zhz";   而非  s="zhz"+s
基础不扎实啊,..惭愧...
字符转化为数字问题,头一次遇到.
从下图,我们可以清楚的看出:
Convert.ToInt32()不会转化字符,或者说它把字符转化为了ASCII码中对应的号,,,但是在开发环境中提示可以有char类型的参数,因为程序中用到了char类型的参数,才偶然发现这个问题

【源码】

 1using System;
 2using System.Data;
 3using System.Configuration;
 4using System.Web;
 5using System.Web.Security;
 6using System.Web.UI;
 7using System.Web.UI.WebControls;
 8using System.Web.UI.WebControls.WebParts;
 9using System.Web.UI.HtmlControls;
10
11
12/*只做简单实现,没有对输入进行验证是否合法(非法字符/长度等)*/
13public partial class _Default : System.Web.UI.Page 
14{
15    protected void Page_Load(object sender, EventArgs e)
16    {
17    }

18    //定义一个枚举类型:数字    
19    enum Number
20    {
21        零,壹, 贰, 叁, 肆, 伍, 陆, 柒, 捌, 玖
22    }

23    //定义一个枚举类型:单位
24    enum UnitPrice_AX_Made_In_China
25    {
26        圆,拾,佰,仟,万
27    }

28    protected void btnSubmit_Click(object sender, EventArgs e)
29    {
30        //把输入的数字打散(txtNumber是一个文本框,用来输入数字)
31        char[] n =(this.txtNumber.Text).ToCharArray();
32        //用来存放显示结果
33        string show = "";
34        for (int i = 0; i <n.Length; i++)
35        {
36            //show+=k  等价于  show=show+k  ,不是我想要的字符串连接
37            show = ((Number)(Convert.ToInt32(n[n.Length - i-1].ToString()))).ToString()+((UnitPrice_AX_Made_In_China)i).ToString()+show;
38        }

39        //lbShow是一个Lable,用来输出结果
40        this.lbShow.Text=show;
41    }

42}