XML comment for main?

In C #, I wrote an XML comment for the main method:

 /// <summary> /// Some comment. /// </summary> public static void Main(string[] args) { 

But Visual Studio warns me about this:

 XML comment is not placed on a valid language element main 

What is the recommended way to comment on the main method in C #?

+4
source share
3 answers

Some language elements are not allowed to have xml documentation, such as a namespace and, obviously, in this case also the main methods. The documentation talks about this, and also has some links that show what other XML do and don’t do.

The only hacker answer I could offer is if you want to comment on it, just use double quotes // instead of three. The triples are processed in the documentation for the class and are likely to cause background problems.

+2
source

I think you also need to post comments for the parameters.

 /// <summary> /// /// </summary> /// <param name="args"></param> static void Main(string[] args) { 

I think this is what VS is looking for. After writing the method, just type /// above the method. At least this does not give any errors / warnings in my Visual Studio.

Hope this helps.

+2
source

I would like to add a sentence to it. Go to the project property β†’ Build, and then check the box indicating the XML documentation file before you start writing XML documentation. This will help you when writing XML tags. If you put an invalid XML tag, say, over a namespace, then VS will suggest: XML comment does not fit into a valid language element.

+1
source

Source: https://habr.com/ru/post/1492053/


All Articles