C # tag <exception> not showing

My constructor throws an exception. So I tried adding this line above:

/// <exception cref="System.Exception">Thrown when...</exception>
public Person(int serial)
{
    if(....)
        throw new System.Exception();
}

When I write in Main: Person x = new Person(...it does not show what this exception might cause (in the tooltip window). The same problem occurs with indexer and properties if I want to show it only for Set.

If I write it above the usual other methods, it shows it.

Thanks in advance. Liron.

+4
source share
1 answer

If you do not include the information in the XML comments for the method, property, or field and in the correct format, Visual Studio will not display and display it. For the constructor, the syntax is:

/// <summary>
/// Create a person from a serial number
/// </summary>
/// <exception cref="ArgumentException">Thrown when serial number is outside valid     range</exception>
/// <param name="serial"></param>
public Person(int serial)
{
if (serial == 0)
    {
    throw new ArgumentException("Serial number cannot be zero");
    }
}

, Intellisense !

[] [/edit]

+1

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


All Articles