123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace Bowin.Common.Utility
- {
- public class CheckData
- {
- /// <summary>
- /// 判断日期的格式
- /// </summary>
- /// <param name="dateText">输入日期的字符串</param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 判断正整数的格式
- /// </summary>
- /// <param name="Str"></param>
- /// <returns></returns>
- 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;
- }
- }
- }
|