开发者

Is there a throws keyword in C# like in Java? [duplicate]

开发者 https://www.devze.com 2023-02-28 01:35 出处:网络
This question already has answers here: Closed 11 years ago. Poss开发者_如何学Goible Duplicate: how to use Java-style throws keyword in C#?
This question already has answers here: Closed 11 years ago.

Poss开发者_如何学Goible Duplicate:

how to use Java-style throws keyword in C#?

i have a function where an exception occurs say for example

private void functionName() throws Exception
{
   // some code that might throw an exception
}

thanks!


No, because there are no checked exceptions in C#

If you are trying to document exceptions that are thrown, use the standard xml documentation

/// <exception cref="InvalidOperationException">Why it's thrown.</exception>


No. There is no such construct in c#. But you can add the comment to your method like this /// <exception cref="Exception"></exception> and it will be visible in IntelliSense


Unfortunately there isn't, and it can be a pain. The remedy is to be more careful with the exceptions that your code throws and how you handle errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消