| Home | Site Map | Contact Us |
 Ashtaanga Yoga
 Relaxation Techniques
 Tips for Interview
 Common Interview Questions
 Resume Tips
 Company Profiles
 Jobs Availability
 Companies list
 Indian Market
 World Market
  What is .Net?
  Why .Net?
 ASP.Net Introduction
 App. Development In ASP.Net
 Introduction to C#.Net
 Coding Standards
 Introduction to ADO.Net
 Application Deployment
 Find Your Location
 Watch Online Videos
 Watch Online TV
.Net-> Coding Standards

C# Coding Standards



Superior coding techniques and programming practices are hallmarks of a professional programmer. The bulk of programming consists of making a large number of small choices while attempting to solve a larger set of problems. How wisely those choices are made depends largely upon the programmer's skill and expertise.


The readability of source code has a direct impact on how well a developer comprehends a software system, which in turn directly affects project velocity. Code maintainability refers to how easily that software system can be changed to add new features, modify existing features, fix bugs, or improve performance. Although readability and maintainability are the result of many factors, one particular facet of software development upon which all developers have an influence is coding technique. The easiest method to ensure that a team of developers will yield quality code is to establish a coding standard, which is then enforced at routine code reviews. Although the primary purpose for conducting code reviews throughout the development life cycle is to identify

defects in the code, the reviews can also be used to enforce coding standards in a uniform manner.


A comprehensive coding standard encompasses all aspects of code construction and, while developers should exercise prudence in its implementation, it should be closely followed. Completed source code should reflect a harmonized style, as if a single developer wrote the code

in one session.



One Class per File


Source files should contain one class definition per source file. Said differently, each class definition will exist within its own file. The stem of the file name must be the same name as the name used in the class declaration. For example, the class definition for a class named Loan will have a file name of Loan.cs.




C# source files have the following ordering:

using statements

namespace statement

Class and interface declarations


Namespace and Using Statements


The first non-comment lines of most C# source files is the using statements. After that, namespace statements can follow. For example:


using System.Data;

namespace Business.Framework;


Ø     Both the using statement and the namespace statement are aligned flush against the left margin.

Ø     The first letter of a component in a namespace is always capitalized. If the namespace name is an acronym, the first letter only of the namespace will be capitalized, as in System.Data.Sql.

Ø     If the acronym only has two letters, both letters are capitalized, as in System.IO.


XML Documentation


Visual Studio provides for a type of documentation that the development environment is able to detect and extract to structured XML that is used to create code-level documentation that exists outside of the source code itself.

XML documentation is provided for class descriptions, methods, and properties. XML documentation should be used in all circumstances where it's available.

Refer to the detailed discussion on XML documentation in this document as well as in the documents provided with Visual Studio .NET.