Question

I am writing c#. Exceptions can be in many other languages I don't understand how works exception handling, how "try/catch". I know that error in "try block" go to "catch block". "Catch" can catch different situation how:

  1. all errors
  2. ArithmeticException
  3. DivideByZeroExeption
  4. other exeption

Some exeptions I can find in MSDN, some can be common, like arithmetic exception.

But how can I be sure that method has these exceptions? I want to understand this question. For example in various frameworks, I see method name, but not see method itself.

Was it helpful?

Solution

But how i can be sure that method has these exceptions?

You can read documentation of that method.You will see a section named Exceptions,that list contains exceptions that method can possibly throw.For example take a look at the int.Parse method documentation, you will see these exceptions in Exception list:

  1. ArgumentNullException
  2. FormatException
  3. OverflowException

OTHER TIPS

You can look on MSDN, when you lookup a function/method at the end of the page there's always the list of exceptions that can occur using this function/method. Then if you want to know why these can occur, just click on the exceptions and they will explain on an other web page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top