How do I make visual studio show exceptions that a

2020-03-03 04:57发布

I was wondering about how I can make visual studio show the exceptions that any method may throw, not just the .NET Framework methods (I am using C#).

For example, here's a picture showing that when I hover over Console.WriteLine it says "Exceptions: System.IO.IOException".

enter image description here

However when I do that for any method I wrote it doesn't say what exception it throws, as shown in the following picture.

enter image description here

So how do I make visual studio show those exceptions? Do I need to add a specific attribute to the method?

1条回答
我命由我不由天
2楼-- · 2020-03-03 05:36

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

/// <summary>
/// Fooes this instance.
/// </summary>
/// <exception cref="ArgumentNullException">Yay for exception</exception>
public void Foo()
{ }
查看更多
登录 后发表回答