C#标签没有显示 [英] C# tag not showing

查看:76
本文介绍了C#标签没有显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的构造函数抛出异常。所以我试着在它上面加上这一行:



///< exception cref =System.Exception>抛出......

public Person(int serial)

{

if(....)

抛出新的System.Exception();

}

当我在Main中写道:Person x = new Person(...它没有显示可能抛出的异常(在工具提示框中)。同样的问题也出现在索引器和属性中,如果我只想为Set显示它。



如果我把它写在常规的其他方法之上,它确实显示它。



提前谢谢

My constructor throws an exception. So I tried to add this line above it:

/// <exception cref="System.Exception">Thrown when...
public Person(int serial)
{
if(....)
throw new System.Exception();
}
When I write in Main: Person x = new Person(... it doesn't show what exception this might throw (in the tooltip box). The same problem occurs also with indexer and in properties, if I want to show it only for Set.

If I write it above regular other methods, it does show it.

Thanks in advance

推荐答案

你必须像下一个例子那样评论你的构造函数:

You have to comment your constructor like in the next example:
/// <summary>
/// Your class comment...
/// </summary>
/// <exception cref="AccessViolationException">Your comment...</exception>
public Person(int serial)
{
...
}

如果您不在XML c中包含这些信息方法,属性或字段的省略,以及正确的格式,Visual Studio将不会拾取并显示它。

对于构造函数,语法将是:

If you do not include the information in the XML comments for a method, property, or field, and in the correct format, Visual studio will not pick it up and display it.
For a Constructor, the syntax would be:
/// <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 for constructors 中不会显示异常信息!



[edit]轻微澄清[/ edit]

Unfortunately, even with this, exception information isn't displayed in Intellisense for constructors only in the generated documentation files!

[edit]Minor clarification[/edit]


这篇关于C#标签没有显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆