{ Console.Write("More? -1 to end: ");
            Mr = Convert.ToInt32(Console.ReadLine());
            if (Mr == -1)
            {
                Console.WriteLine("Goodbye");
                break;
            }
            }while(Mr == 1);只能输入1或-1。输入的是1时,继续循环,是-1时,终止循环。如何验证。

解决方案 »

  1.   

    { Console.Write("More? -1 to end: ");
                Mr = Convert.ToInt32(Console.ReadLine());
                if (Mr == -1)
                {
                    Console.WriteLine("Goodbye");
                    break;
                }
    else
    {
      Mr = Convert.ToInt32(Console.ReadLine());}
                }while(Mr == 1);
      

  2.   

    Mr = Convert.ToInt32(Console.ReadLine());
      if (math.abs(Mr)== -1)
      {
      Console.WriteLine("Goodbye");
      break;
      }
    else
    {
      Mr = Convert.ToInt32(Console.ReadLine());}
    }while(math.abs(Mr) != 1);
      

  3.   

    string Mr;
    do{ 
    Console.Write("More? -1 to end: ");
                Mr = Console.ReadLine();
                if (Mr != '-1'||Mr!='1')
                {
                    Console.WriteLine("输入错误,请输入正确数字");
                    continue;
                }
    else{
    ...
    }
                }while(1 == 1);
      

  4.   

    != 是不能用来判定string的
      

  5.   

    另外Mr != '-1'||Mr!='1' 应该是&&。不过还是感谢