怎么判断日期妥当性? 简单的方法:try{DateTime.Parse(txtCreateDate.Text)}catch{} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 super76(龙) 说的有道理也可以这样的try{Convert.ToDateTime(strDate);}catch(Exception h){MessageBox.Show(h.Message);} Hexudong1979(何须懂何必懂) 的方法好 string test = "200q1219";//20031219是ok的,如果200q1219就不行 System.Text.RegularExpressions.Regex reg = new Regex(@"\b(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})\b" ); bool flag = reg.IsMatch(test); if (flag==false) { MessageBox.Show("no"); }else { MessageBox.Show("yes"); } 关于日期的正则表达式,可以到这里看看http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=4&categoryId=5 bool fIsDateAvailable(){ try{ Convert.ToDateTime(strDate); } catch{ return false; } return true;} tjq_tang(过河兵):string test = "20031233",它返回出来是true,但是string test = "20031212",它返回出来还是true,为什么阿? 可以在检验函数中加上日期的上限下限在这个区间返回true 否则false DataTable如何实现排序 C# webBrowser 嵌入资源中的html文件,html中引用的资源要怎么处理 C#中调用Excel中的宏 我想启动一个程序时首先查看另一个程序是否已经启动,如未启动就退出(或自动把他启动起来),如何处理? 用OleDbConnection连接sybase服务器,如何写连接语句呢 mysql迁移到oracle关于存储过程的迁移问题 急急急!求大神搭救 如何改变datagrid中单个字符的颜色?? .net 开发模式 switch的使用 生成项目时出错信息“aa.exe未定义入口点” 谁有水晶报表的使用说明?
try{
Convert.ToDateTime(strDate);
}
catch(Exception h)
{
MessageBox.Show(h.Message);
}
{
MessageBox.Show("no"); }else
{
MessageBox.Show("yes");
}
http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=4&categoryId=5
{
try{
Convert.ToDateTime(strDate);
}
catch{
return false;
}
return true;
}
string test = "20031233",它返回出来是true,但是string test = "20031212",它返回出来还是true,为什么阿?
在这个区间返回true
否则false