How to write comments / documentation for variables / fields / lists in VS 2010?

后端 未结 6 1035
挽巷
挽巷 2020-12-15 05:46

There is

///
///This is summary for some class or method
///

documentation for classes or methods. But how t

相关标签:
6条回答
  • 2020-12-15 06:30

    Seems to work perfectly fine in Visual Studio 2010. I defined a List as a private field with a comment inside my MainForm class.

    They won't work for local variables defined within functions though.

    enter image description here

    0 讨论(0)
  • 2020-12-15 06:35

    Edit: it looks like <var> is only supported for JavaScript.

    As of Visual Studio 2012 you can add this documentation using the <var> element.

    Here's Microsoft's documentation on it:
    https://msdn.microsoft.com/en-us/library/hh542722(v=vs.110).aspx

    0 讨论(0)
  • 2020-12-15 06:38

    As far as I know, adding comments for intellisense will not work for local variables declared within functions. If you were to make your local list an instance variable of the class, you would be able to do this.

    0 讨论(0)
  • 2020-12-15 06:42

    As others mentioned, you can't get IntelliSense for local vars. However: If your function is so large that a "regular" comment is not close enough to read near the place where you're using the var, then the right fix is to refactor the function -- break it up into multiple, smaller methods, with fewer vars. I don't think this feature should exist, as it would serve only to facilitate writing excessively large functions.

    0 讨论(0)
  • 2020-12-15 06:44

    The same way as you write summary for classes and methods work for variables.

    0 讨论(0)
  • 2020-12-15 06:48

    You can add such XML documentation comments to any class member, not inside a member (method, property, etc).

    0 讨论(0)
提交回复
热议问题