c#中如何判断字符串是否为数字

使用正则表达式:using System.Text.RegularExpressions;string pattern = @^/d+(/./d)?$;if(Text1.Text.Trim()!=){if(!Regex.IsMatch(sign_money.Text.Trim(),pattern)){Text1不是数字;}else{Text1是数字;}}---------------------- …… 阅读全文

C#验证输入的是否数字的方法

其实用正则表达式也可以 static bool IsNumeric(string str) { if (str==null || str.Length==0) return false; foreach(char c in str) { if (!Char.IsNumber(c)) { return false; } } return true; } 正则表达的写法是: static bool I …… 阅读全文

用C#语言构造蜘蛛程序

"蜘蛛"(Spider)是Internet上一种很有用的程序,搜索引擎利用蜘蛛程序将Web页面收集到数据库,企业利用蜘蛛程序监视竞争对手的网站并跟踪变动,个人用户用蜘蛛程序下载Web页面以便脱机使用,开发者利用蜘蛛程序扫描自己的Web检查无效的链接……对于不同的用户,蜘蛛程序有不同的用途。那么,蜘蛛程序到底是怎样工作的呢?   蜘蛛是一种半自动的程序,就象现实当中的蜘蛛在它的Web(蜘蛛网)上旅行 …… 阅读全文

C#读取网站的数据

以下是引用片段:Form1.cs using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Xml; namespace hellojoysou { /// …… 阅读全文

C#学习笔记

1,MDI窗体设有两个窗体frmMain,frmChild,则:frmMain: 设IsMdiContainer属性为true打开子窗口:在相关事件中写如下代码:frmChild child=new frmChild();child.MdiParent=this;//this表示本窗体为其父窗体child.Show();在打开子窗体时,如果只允许有一个子窗体,可以加入如下判断:if (this.A …… 阅读全文

Visual C#常用函数和方法集汇总

1、DateTime 数字型 System.DateTime currentTime=new System.DateTime();   1.1 取当前年月日时分秒 currentTime=System.DateTime.Now;   1.2 取当前年 int 年=currentTime.Year;   1.3 取当前月 int 月=currentTime.Month;   1.4 取当前日 int …… 阅读全文