找到异常的类型 [英] Find the type of the exception
问题描述
我一直在努力解决以下问题:
如何找到异常的类型?换句话说,我会
喜欢提出以下代码(用伪代码写成
):
if(exception.Type()== outOfMemoryException)
then
......
注意在这种情况下我不能使用catch语句。
建议将受到高度赞赏。
谢谢,
Greg
I have been struggling with the following issue:
How can one find the type of the exception? In other words I would
likes to come up with piece of code that does the following (written
in pseudo code):
if (exception.Type() == outOfMemoryException)
then
......
Note that I can''t use catch statement in this case.
Suggestions will be highly appreciated.
Thanks,
Greg
推荐答案
你可以使用是在这种情况下:
if(异常是OutOfMemoryException)
{}
Alex
< a rel =nofollowhref =http://devkids.blogspot.comtarget =_ blank> http://devkids.blogspot.com
我一直在努力解决以下问题:
如何找到异常的类型?换句话说,我会
喜欢提出以下代码(用伪代码写成
):
if(exception.Type()== outOfMemoryException)
then
.....
请注意,我不能在这种情况下使用catch语句。
建议将受到高度赞赏。
谢谢,
Greg
I have been struggling with the following issue:
How can one find the type of the exception? In other words I would
likes to come up with piece of code that does the following (written
in pseudo code):
if (exception.Type() == outOfMemoryException)
then
.....
Note that I can''t use catch statement in this case.
Suggestions will be highly appreciated.
Thanks,
Greg
6月9日上午12:07,greg< greg.johnse ... @ gmail.comwrote:
On Jun 9, 12:07 am, greg <greg.johnse...@gmail.comwrote:
我一直在努力解决以下问题:
如何找到异常的类型?换句话说,我会
喜欢提出以下代码(用伪代码写成
):
if(exception.Type()== outOfMemoryException)
then
.....
注意我在这种情况下不能使用catch语句。
建议将受到高度赞赏。
谢谢,
Greg
I have been struggling with the following issue:
How can one find the type of the exception? In other words I would
likes to come up with piece of code that does the following (written
in pseudo code):
if (exception.Type() == outOfMemoryException)
then
.....
Note that I can''t use catch statement in this case.
Suggestions will be highly appreciated.
Thanks,
Greg
我不认为如果不使用
这个catch块就可以获得例外类型。在这种情况下代码只是打破说未处理
异常发生。
I don''t think it''s possible to get the type of excepion without using
the catch block. In this case code just breaks saying unhandled
exception has occured.
你可以做以下
Catch(Exception ex)
{
if(ex is outOfMemoryException)
{
//做我需要的事情
}
其他
{
throw;
}
}
- José
" greg" < gr ************ @gmail.comaécritdansle message de news:
11 ******** @ g37g2000prf.googlegroups。 com ...
You can do the following
Catch (Exception ex)
{
if (ex is outOfMemoryException)
{
// do what I need
}
else
{
throw;
}
}
- José
"greg" <gr************@gmail.coma écrit dans le message de news:
11**********************@g37g2000prf.googlegroups. com...
>我一直在努力解决以下问题:
如何才能找到例外的类型?换句话说,我会
喜欢提出以下代码(用伪代码写成
):
if(exception.Type()== outOfMemoryException)
then
.....
注意我在这种情况下不能使用catch语句。
建议将受到高度赞赏。
谢谢,
Greg
>I have been struggling with the following issue:
How can one find the type of the exception? In other words I would
likes to come up with piece of code that does the following (written
in pseudo code):
if (exception.Type() == outOfMemoryException)
then
.....
Note that I can''t use catch statement in this case.
Suggestions will be highly appreciated.
Thanks,
Greg
这篇关于找到异常的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!