问题描述
专家们
我上课了
Hi experts
I made a class
public class Test
{
public Name {get; set;}
public void SetName()
{
// code
}
}
例如,当您键入Conosole时,您看到了Visual Studio自动完成功能.写入后会显示一个工具提示并说:
You saw visual studio autocomplete for example when you type Conosole.Write then a tooltip is shown and says:
void Console.Write(string value) (+17 overload(s))
Write the specific string value to the standard output stream.
Exceptions:
System.IO.IOException
我上课要这样的东西.我使用了Description属性,但没有用.
I want something like this for my class. I used Description attribute but it did not work.
public class Test
{
[Description("Something1"]
public Name {get; set;}
[Description("Something2"]
public void SetName()
{
// code
}
}
问题是:如何为我的方法和属性设置一些描述,使其在其他程序员使用该类时可以显示出来.就像一些内置类.
感谢
The question is: How can set some description for my mehtods and properties that it can be shown when the other programmers are using the class. like some built in classes.
thanks
推荐答案
/// <summary>
/// Sets the name of the widget.
/// </summary>
public void SetName()
{
// ...
}
///
或
/**
...
*/
如您所见,C#通过这种方式将标记视为注释.在要记录的类型或成员之前的一行开始输入"///",Visual Studio将为您创建一个简约的注释模板.
在此类注释中,您可以编写特殊格式的XML文档来表示方法,参数,交叉引用等.
请参阅:
http://msdn.microsoft.com/en-us/library/b2s063f7.aspx [ ^ ].
它会在一个特殊文件中创建文档,默认情况下会创建该文件并将其仅用于Debug配置,但是您可以在项目属性中对其进行更改-请参见构建"选项卡"XML文档文件".
享受,
As you can see, in this way C# recognized such markup as comments. Start typing "///" one the line before a type or a member to be documented, and Visual Studio will create a minimalistic comment template for you.
Inside such comments, you can write specially formatted XML documentation to denote methods, parameters, cross-references, etc.
Please see:
http://msdn.microsoft.com/en-us/library/b2s063f7.aspx[^].
It creates the documentation in a special file which is, by default, is created and used only for Debug configuration, but you can change it in the project properties — please see the tab "Build", "XML Documentation file".
Enjoy,
这篇关于如何为我们的方法和属性设置简要说明.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!