Curro
Curro

Reputation: 852

How to use inline comments to document members in .NET?

How can I document a member inline in .Net? Let me explain. Most tools that extract documentation from comments support some kind of inline documentation where you can add a brief after the member declaration. Something like:

public static string MyField; /// <summary>Information about MyField.</summary>

Is there a way to do this in C# or the .NET languages?

Upvotes: 7

Views: 5479

Answers (3)

Robert S.
Robert S.

Reputation: 25294

There is not a built-in way to do this. The XML documentation system is hierarchical; it defines a relationship between the tag <summary /> and the data that immediately follows it.

Upvotes: 2

Scott Dorman
Scott Dorman

Reputation: 42516

No, you can't. XML comments are only supported as a block level comment, meaning it must be placed before the code element you are documenting. The common tools for extracting XML comments from .NET code do not understand how to parse inline comments like that. If you need this ability you will need to write your own parser.

Upvotes: 7

GeekyMonkey
GeekyMonkey

Reputation: 12974

Yep, just put it BEFORE the thing you want to comment

/// <summary>Information about MyField.</summary>
public static string MyField; 

Upvotes: 1

Related Questions