Solved

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

Posted on 2012-03-28
5
332 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now