//禁止 非数字      禁止 全相同数字
                                                            if (!Regex.IsMatch(cardPass, @"\d{6}") || Regex.IsMatch(cardPass, @"(\d)\1{5}"))
                                                            {
                                                                isSpecialAllowed = false;
                                                            }
                                                            else
                                                            {
                                                                //禁止顺序 倒序                                                            }

解决方案 »

  1.   

    void Main()
    {
           string cardPass="654311";
    if (!Regex.IsMatch(cardPass, @"^\d{6}$") || Regex.IsMatch(cardPass, @"^(\d)\1{5}$"))
    {
    //isSpecialAllowed = false;
    }
    else

          if(!IsOrdered(cardPass) || !IsOrdered(new string(cardPass.ToCharArray().Reverse().ToArray())))
      {
      //禁止顺序 倒序   } }
    }
    static bool IsOrdered(string testStr)
    {
    if (string.IsNullOrEmpty(testStr))
    return false;
      
    int count = testStr.Length; for (int i = 0; i < count - 1; i++)
    {
    if (testStr[i + 1] <= testStr[i])
    return false;
    }
    return true;
    }