How to make visual studio exceptions that any method can call?

I was wondering how can I make visual studio show exceptions that any method can use, and not just .NET Framework methods (I use C #).

For example, it shows here that when I hover over Console.WriteLine, it says “Exceptions: System.IO.IOException”.

enter image description here

However, when I do this for any method that I wrote, it does not say which exception it throws, as shown in the following figure.

enter image description here

So, how do I make a visual studio show these exceptions? Do I need to add a specific method to a method?

+6
source share
1 answer

You can do this by adding the <exception> to the methods comment:

 /// <summary> /// Fooes this instance. /// </summary> /// <exception cref="ArgumentNullException">Yay for exception</exception> public void Foo() { } 
+14
source

Source: https://habr.com/ru/post/989618/


All Articles