随笔分类 -  C#

判断字符串中是否含有数字
摘要://判断字符串中是否含有数字 public bool isExists(string str) { return Regex.Matches(str, "[0-9]").Count > 0; } 阅读全文
posted @ 2012-02-10 15:26 张@天 阅读(358) 评论(0) 推荐(0)
把数字转换成大写字
摘要://把123456...转换成:壹、贰、叁、肆、伍、陆...public string isNumberMax(string strChineseName) { string[] cnNum = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; for (int i = 0; i < 10; i++) { strChineseName 阅读全文
posted @ 2012-02-10 15:16 张@天 阅读(1070) 评论(0) 推荐(0)
C#遍历指定文件夹中的所有文件
摘要:DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);//遍历文件夹foreach(DirectoryInfo NextFolder in TheFolder.GetDirectories()) this.listBox1.Items.Add(NextFolder.Name);//遍历文件foreach(FileInfo NextFile in TheFolder.GetFiles()) this.listBox2.Items.Add(NextFile.Name);================================== 阅读全文
posted @ 2011-09-15 14:34 张@天 阅读(273) 评论(0) 推荐(0)
asp.net c# 打开新页面或页面跳转
摘要:1.最常用的页面跳转(原窗口被替代):Response.Redirect("XXX.aspx");2.利用url地址打开本地网页或互联网:Respose.Write("<script language='javascript'>window.open('"+ url+"');</script>");3.原窗口保留再新打开另一个页面(浏览器可能阻止,需要解除):Response.Write("<script>window.open('XXX.aspx& 阅读全文
posted @ 2011-09-05 11:01 张@天 阅读(444) 评论(0) 推荐(0)
C# 判断字符串中是否含有字母
摘要:方法一:用正则表达式的方法//引用的命名空间using System.Text.RegularExpressions;public bool isExists(string str) { return Regex.Matches(str, "[a-zA-Z]").Count > 0; }方法二:#region 判断字符串是否有字母 /// <summary> /// 名称:IsAllChar /// 判断文本是否全是字母组合 /// </summary> /// <param name="text">需判断的文本 阅读全文
posted @ 2011-09-02 11:36 张@天 阅读(9506) 评论(0) 推荐(0)
c#中字符串操作函数
摘要:Len Len(string|varname) 返回字符串内字符的数目,或是存储一变量所需的字节数。 Trim Trim(string) 将字符串前后的空格去掉 Ltrim Ltrim(string) 将字符串前面的空格去掉 Rtrim Rtrim(string) 将字符串后面的空格去掉 Mid Mid(string,start,length) 从string字符串的start字符开始取得length长度的字符串,如果省略第三个参数表示从start字符开始到字符串结尾的字符串 Left Left(string,length) 从string字符串的左边取得length长度的... 阅读全文
posted @ 2011-09-02 11:33 张@天 阅读(3096) 评论(0) 推荐(1)