如何为自定义创建的类获得智能感应?[英] How to get intellisense for custom created classes?

本文是小编为大家收集整理的关于如何为自定义创建的类获得智能感应?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

输入"此"时. ,通常您会获得所有的例程,事件以及更多...您所在的当前课程.当您只能站在长列表中的一个例程中而无需选择一个例程时,通常会在旁边得到描述.

我该怎么做? 假设我有一个名为CAR的类,带有两个例程:speed_up()和brake(). 我该如何使该人使用我的班级来查看这两个功能的描述:

CAR mycar = new CAR();
mycar.

推荐答案

上方或方法上方,而不是"//"注释.如果您执行"///"三重斜杠(也称为XML注释),则可以执行捷径,以允许您填写有关您要评论的类或方法的信息.

然后,这出现在您的代码中

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void Method(object sender, EventArgs e)

然后,当您通过IntelliSense访问类或方法时,当说明出现时.

其他推荐答案

给您的课堂及其成员, xml注释,它将出现在 IntelliSense .在Visual Studio中进行此操作的最简单方法是在要在要添加评论的内容上键入///

例如:

/// <summary>
/// Class level summary documentation goes here.</summary>
/// <remarks>
/// Longer comments can be associated with a type or member through
/// the remarks tag.</remarks>
public class TestClass : TestInterface
{
    /// <summary>
    /// Store for the name property.</summary>
    private string _name = null;

    /// <summary>
    /// The class constructor. </summary>
    public TestClass() { }

    /// <summary>
    /// Description for SomeMethod.</summary>
    /// <param name="s"> Parameter description for s goes here.</param>
    /// <seealso cref="System.String">
    /// You can use the cref attribute on any tag to reference a type or member 
    /// and the compiler will check that the reference exists. </seealso>
    public void SomeMethod(string s)
    {
    }
}

以上找到了在这里..


另请参见:您如何获得XML评论出现在另一个项目(DLL)中?

其他推荐答案

您应该使用Visual Studio中可用的XML文档格式用于每个类型的构造(即类,方法,属性...)

要访问它,在声明之前在行上键入///.

例如:

  ///
  public void Method(string p){...

您会得到类似的东西:

  /// <summary>
  /// 
  /// </summary>
  /// <param name="p"></param>
  public void Method(string p){...

如果您键入///<您甚至会获取可用的XML元素列表,例如备注或示例 有关更多信息,请参见 http://msdn.microsoft.com/en-en-us/杂志/cc302121.aspx

本文地址:https://www.itbaoku.cn/post/425527.html

问题描述

When you type "this." , you usually get all the routines, events, and more... of the current class you are in. And when you simply stand over one of the routines in the long list without choosing one, you usually get a description next to it.

How can I do that ? Let assume I have a class called CAR with two routines: speed_up(), and brake(). How can I make the person using my class to see a description of the two functions when he types:

CAR mycar = new CAR();
mycar.

推荐答案

Above a class or a method, rather than a "//" comment. if you do a "///" triple slash ( otherwise known as an XML comment ), it performs a short cut to allow you to fill information out about the class or method you are commenting on.

This then appears in your code as such

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void Method(object sender, EventArgs e)

When you then access the class or method through intellisense thats when the description will appear.

其他推荐答案

Give your classes and their members, XML comments, which will appear in intellisense. The easiest way of doing this in visual studio is by typing /// above what you want to add comments to.

For example:

/// <summary>
/// Class level summary documentation goes here.</summary>
/// <remarks>
/// Longer comments can be associated with a type or member through
/// the remarks tag.</remarks>
public class TestClass : TestInterface
{
    /// <summary>
    /// Store for the name property.</summary>
    private string _name = null;

    /// <summary>
    /// The class constructor. </summary>
    public TestClass() { }

    /// <summary>
    /// Description for SomeMethod.</summary>
    /// <param name="s"> Parameter description for s goes here.</param>
    /// <seealso cref="System.String">
    /// You can use the cref attribute on any tag to reference a type or member 
    /// and the compiler will check that the reference exists. </seealso>
    public void SomeMethod(string s)
    {
    }
}

The above was found here.


See also: How do you get XML comments to appear in a different project (dll)?

其他推荐答案

You should use the XML documentation format available in Visual studio for every type constructs (ie class, methods, properties...)

To access it, type /// on the line before your declaration.

For instance:

  ///
  public void Method(string p){...

you will get something like:

  /// <summary>
  /// 
  /// </summary>
  /// <param name="p"></param>
  public void Method(string p){...

if you type ///< you will even get the list of available XML elements, like remarks or exemple For more informations, see http://msdn.microsoft.com/en-us/magazine/cc302121.aspx