Solved

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

Posted on 2012-03-28
5
334 Views
Last Modified: 2012-04-03
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
Comment
Question by:Eindoofus
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:tony_techtoneic
ID: 37779992
0
 

Author Comment

by:Eindoofus
ID: 37780004
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
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
ID: 37780093
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
 

Author Comment

by:Eindoofus
ID: 37780154
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
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 37780554
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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Code works but it's slow 28 72
Graphics 2 30
Jquery/JSON passing value from one function to another 12 41
C# Gridview 1 34
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question