Solved

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

Posted on 2012-03-28
5
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

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…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

734 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