using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace Bowin.Common.Utility { public class CheckData { /// /// 判断日期的格式 /// /// 输入日期的字符串 /// public static bool isDataFormal(string dateText) { bool result = false; if (dateText.Length > 0) { DateTime dtstate = DateTime.MinValue; DateTime.TryParse(dateText, out dtstate); if (dtstate != DateTime.MinValue) { result = true; } } else { result = true; } return result; } /// /// 判断正整数的格式 /// /// /// public static bool isPositiveInt(string Str) { bool _isPositiveInt = false; string matchStr = ""; matchStr += @"^[1-9]\d*$"; RegexOptions option = (RegexOptions.IgnoreCase | (RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace)); if (Regex.IsMatch(Str, matchStr, option)) _isPositiveInt = true; else _isPositiveInt = false; return _isPositiveInt; } } }