Reputation:
I am new to development and wanted to ask a very basic question, I was looking some code in C# and trying to reproduce the application I am not getting what to do when I come across param tag with three slash, check out the below example :-
/// <param name="requestMethod">one of GET, PUT, DELETE</param>
Two & three slashes are used for comments, so is this a comment or I need to remove comment and put the value as described.
Thanks in advance..
Upvotes: 2
Views: 206
Reputation: 5284
Three slashes ///
are XML comments whereas two slashes //
are just standard comments found in the code.
So as you can see the XML comment with the three slashes has information about the method as a whole, whereas the //
comment in the main body of the method is just a comment about a part of that method.
/// <summary>
/// Does something.
/// </summary>
///<param name="param1">The parameter .</param>
public void doSomething(int param1)
{
// This is a standard comment about some code
}
So when calling this method you would do:
doSomething(999)
The Line ///<param name="param1">The parameter .</param>
Means that this method expects you to pass in something as a parameter
For more info about using XML methods see here : http://msdn.microsoft.com/en-us/magazine/cc302121.aspx
Upvotes: 1
Reputation: 5434
It's for documenting code.
From above link:
the 'param' tags define each parameter
In your example, the document is describing the values that can be passed into requestMethod
. Without seeing the method signature, it's hard to determine if these values are the strings GET
, PUT
, and DELETE
or possibly C# enum values.
See also article from MSDN
Upvotes: 1
Reputation: 2261
This is just a special kind of comment.
In Visual Studio if you press /// above a method it will automatically create the information for you, based on the current method.
This is used for documentation and and you can get the compiler to generate an xml file with this information with the /doc commandline option.
See Microsofts recommendations:
http://msdn.microsoft.com/en-us/library/5ast78ax.aspx
Upvotes: 0