使用方法做要求输入第一个数字大于第二个数字

       static void Main(string[] arr)
        {
            int[] shuZi;
            
            bool bj = false;
            while (!bj)
            {
                shuZi = Test();
                bj = BiJiao(shuZi[0], shuZi[1]);
                  }
            Console.WriteLine("ok");
            Console.ReadKey();
        }

        public static int[] Test()
        {
            int n1=0;
            int n2=0;
            try
            {
                Console.WriteLine("请输入数字1");
                n1 = ZhuanHuan();
                Console.WriteLine("请输入数字2");
                n2 = ZhuanHuan();

            }
            catch
            {
                Console.WriteLine("请输入正确的数字");
                Test();
            }
            int[] intSz=new int[2];
            intSz[0]=n1;
            intSz[1]=n2;
            return intSz;
            
        }
        public static int ZhuanHuan()
        {
            int numbers = Convert.ToInt32(Console.ReadLine());
            return numbers;
        }

        public static bool BiJiao(int n1, int n2)
        { 
            bool bj=false;
            if (n1 > n2)
            {
                bj = true;
            }
            return bj;
        }

 

posted @ 2015-05-10 15:54  自由无风  阅读(286)  评论(0编辑  收藏  举报