不同之处
try
{
...
}
catch (NHibernate.ADOException exception)
{}
以及
try
{
...
}
catch (exception ex)
{}
不同之处
try
{
...
}
catch (NHibernate.ADOException exception)
{}
以及
try
{
...
}
catch (exception ex)
{}
在渔获区,你具体说明了你希望捕获的例外情况。 因此,
try {}
catch(Exception e){}
它将涵盖由例外类别产生的所有例外(所有例外)。 如果有:
try{}
catch (NHibernate.ADOException exception){}
它将只捕获来自或来自《发展权利宣言》的例外情况。 因此,如果你收到“阿古特约”,就会像没有尝试/捕获物一样通过。
我假定你指的是你。
catch (Exception ex) {}
和第二版。
然后,区别是,第一种例外情况只能排出一个特定的例外情况,即<代码>NHibernate。 ADOException,而第二种办法则将进入可能被推翻的所有例外的捕获区。
第二种做法通常不正确,因为你要求处理各种可能错误。 然而,从最外面的角度来看,它对于任何通过的例外来说都是一个整体。
强烈建议使用捕获量{例外},因为这实际上掩盖了ug。 在每个可能出现例外的地方,必须只达到预期的例外类型,即使需要写更多的编码线。 当出现意外例外时,方案必须坠毁,这是固定ug的唯一办法。
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...