相关疑难解决方法(0)

你能捕到一个例外<T>哪里有T是什么类型的?

我希望能够捕捉WebFaultException<string>到最具体的一个WebFaultException<T>(T是任何其他类型)作为更一般的情况来处理.这可能吗?

try
{
    // throw exception
}
catch (WebFaultException<string> e)
{
    // handle more specific type
}
catch (WebFaultException<T> e)
{
    // handle more general type
}
catch (Exception e)
{
}
Run Code Online (Sandbox Code Playgroud)

c# generics exception-handling

34
推荐指数
2
解决办法
9171
查看次数

标签 统计

c# ×1

exception-handling ×1

generics ×1