Vee*_*era -1 c# boolean-logic exception
以下是解释我的问题的代码示例:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
try
{
Program.Sample();
Console.ReadLine();
}
catch (Exception)
{
Console.WriteLine("InvalidOperation Exception");
}
}
static bool Sample()
{
int a = 1; int b = 2;
if (a == b) //Some Condition checking
{
return true;
}
else
{ //Is this Proper returning Exception In Boolean method instead of False
throw new InvalidOperationException();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在客户端应用程序中捕获此异常并显示消息,我想知道这是否是正确的方法?
归档时间: |
|
查看次数: |
1760 次 |
最近记录: |