简体   繁体   English

我怎么知道一个类会抛出什么样的异常?

[英]How can i know what kind of exception a class will throw?

is there any page from MSDN or somewhere can tell us, what kind of exception will be throw from a specific class? 从MSDN或某处可以告诉我们任何页面,特定类会抛出什么样的异常?

for example, FtpWebRequest. 例如,FtpWebRequest。 how can i find out what kind of exception it will throw?? 我怎么能找出它会抛出什么样的异常? the page from MSDN is not really helpful http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest%28v=VS.100%29.aspx 来自MSDN的页面并不是真的有用http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest%28v=VS.100%29.aspx

Thanks 谢谢

Classes don't throw exceptions. 类不会抛出异常。 Members (Properties and Methods) do. 成员(属性和方法)做。 So you need to look at the documentation for the individual members to know. 因此,您需要查看各个成员要了解的文档。

As others said, the intellisense will tell you. 正如其他人所说,智能感知会告诉你。 In addition, you could step into the framework code itself . 此外,您可以进入框架代码本身

In addition, the documentation for each method contains the list of exceptions it might throw. 此外,每个方法的文档都包含它可能抛出的异常列表。 Example . 例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM