注册 登录
编程论坛 C# 论坛

为什么这个异常捕获机制没有起作用?

午夜小学徒 发布于 2014-09-24 17:20, 433 次点击
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01第四天学习
{
    class Program
    {
        static void Main(string[] args)
        {
             Console.WriteLine("请输入您的QQ号:");
              string QQ = Console.ReadLine();
             Console.WriteLine("请输入你的密码:");
              string mima = Console.ReadLine();
            try
            {
                if (QQ == "19045584" && mima == "654321")
                {
                    Console.WriteLine("登录成功!");
                }
            }
            catch {
                Console.WriteLine("用户名与密码不符,请重新输入,谢谢合作!");
            }
            Console.ReadKey();
        }
    }
}
请各路大虾指点!!!
2 回复
#2
邓士林2014-09-24 17:54
你那不属于异常,如:分母为0,数据库没开启去操作之类的才为异常,你这不是异常。
#3
午夜小学徒2014-09-25 16:14
回复 2 楼 邓士林
额,我晕!
1