C# 在try catch(C,窗口服务)中获取错误消息
是否有可能在C上的try catch或Windows服务中获得用C编写的错误消息,如下所示:C# 在try catch(C,窗口服务)中获取错误消息,c#,C#,是否有可能在C上的try catch或Windows服务中获得用C编写的错误消息,如下所示: string input = Console.ReadLine(); while (input!="q") { try { double result = 10 / int.Parse(input); Console.WriteLine("Divinced by " + input + " And result is " + result); }
string input = Console.ReadLine();
while (input!="q")
{
try
{
double result = 10 / int.Parse(input);
Console.WriteLine("Divinced by " + input + " And result is " + result);
}
catch (Exception)
{
Console.WriteLine("Error, Please try again");
}
finally
{
input = Console.ReadLine();
}
}
它是根据.exe程序构建的。
如果我输入字符A、B、C或零,那么程序将显示错误消息,请重试,以便我需要知道错误消息。
我不想编辑代码。我需要一个工具来检测程序中的所有错误
感谢您的帮助。您希望打印异常的消息属性。用以下内容替换挡块:
catch (Exception e)
{
Console.WriteLine("An exception occurred : " + e.Message);
}
像catch异常e{Console.WriteLinee.Message;}?我不这么认为。我不想编辑任何源代码,因为它是exe文件。我不想编辑代码-用户不想修改代码。请阅读整篇文章。实际上,我需要一些工具来显示错误消息,因为我有一个exe程序,我看不到任何源代码。非常感谢。