• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

Any suggestions on how to comment the top of a C# class file?

Are there any standard practices for adding comments to the top of a C# file? For example, I would imagine that it should include something like the author and date.

I need to submit a C# code file to a potential employer and I'd like to know if their is anything that is considered good practice when labeling a class?
0
Eindoofus
Asked:
Eindoofus
  • 2
  • 2
1 Solution
 
tony_techtoneicCommented:
0
 
EindoofusAuthor Commented:
That seems a bit bloated. I was just hoping for some simple comments that show up in XML for the author and date that I can add to the top before all of my "using" statements.
0
 
Chinmay PatelEnterprise ArchitectCommented:
Hi Eindoofus,

Something like this?
// <copyright file="AssemblyInfo.cs" company="FullStack"> 
// Copyright (c) 2008 All Right Reserved 
// </copyright> 
// <author>Rhys Campbell</author> 
// <email>rhysc@fullstack.co.uk</email> 
// <date>2008-09-10</date> 
// <summary>Contains assembly information.</summary>

Open in new window


Link : http://rhysc.blogspot.in/2008/09/style-cop-and-vs-defaults.html

Regards,
Chinmay.
0
 
EindoofusAuthor Commented:
Thanks. Once last thing, should it be three slashes rather than two? I always thought it was the norm to put /// before XML tags in C#.
0
 
Chinmay PatelEnterprise ArchitectCommented:
XML tags always have ///
and normal code comments can have //

These are not XML comments as such, these are as per the guidelines of StyleCop[http://stylecop.codeplex.com]

You can also use
 - StyleCop
 - FxCop[codeplex] OR Code Analysis [built into Visual Studio for Ultimate Edition - not sure about others]
 - Code Metrics [built into Visual Studio]

This will help you a lot to improve your code.

Regards,
Chinmay.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now