| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Muchinfo.PC.Common.Helpers
- {
- public class TextValidationHelper
- {
- /// <summary>
- /// 验证账号是否合法
- /// </summary>
- /// <param name="account"></param>
- /// <returns></returns>
- public static bool VaildLoginAccount(string srt)
- {
- if (!string.IsNullOrEmpty(srt))
- {
- foreach (var item in srt.ToArray())
- {
- if (item >= 'A' && item <= 'Z' ||
- item >= 'a' && item <= 'z' ||
- item >= '0' && item <= '9'
- )
- continue;
- else
- {
- return false;
- }
- }
- return true;
- }
- return false;
- }
- /// <summary>
- /// 相差月份
- /// </summary>
- /// <param name="d1"></param>
- /// <param name="d2"></param>
- /// <returns></returns>
- public static int DifferMonth(DateTime d1, DateTime d2)
- {
- DateTime max = d1 > d2 ? d1 : d2;
- DateTime min = d1 > d2 ? d2 : d1;
- int yeardiff = max.Year - min.Year;
- int monthdiff = max.Month - min.Month;
- return yeardiff * 12 + monthdiff + 1;
- }
- }
- }
|