.NET Daily


C# Coding Standards Series – Naming Conventions

Posted on .

C# Coding Standards Series – Naming Conventions


This post is part of a series that covers most of notable C# coding standards that you should follow.

You can download the document with all of the post from here: [download id=”2″ format=”1″]

You can see here the other posts within the series.

Terminology and Definitions for Naming Conventions:

Camel Case (camelCase): The first letter of the word is lower case and then each first letter of the part of the word is upper case;

Pascal Case (PascalCase): The first letter of the word is upper case and then each first letter of the part of the word is upper case;

Underscode Prefix (_underscore): The word begins with underscore char and for the rest of the word use camelCase rule;

General Rules

1. Use Pascal Case for Class names:


public class HelloWorld { ... };

2. Use Pascal Case for Method names:


public void SayHello(string name) { ... };

3. Use Camel Case for variables and method parameters:


int totalCount = 0;

void SayHello(string name)
     string fullMessage = "Hello " + name;

4. Avoid all upper case or all lower case names;

5. Do not use Hungarian notation:

Example of Hungarian Notation:

string m_sName; (the prefix m_ means that is a member variable and s means that is a string data type);

6. Avoid abbreviations longer than 5 characters;

7. Avoid using abbreviations unless the full name is excessive:


Good: string address;             Not good: string addr;

8. Use meaningfull, descriptive words for naming variables;

9. Try to prefix Boolean variables with “Can”, “Is” or “Has”;

10. Do not use Underscore Prefix for local variables names;

11. All member variables must use Underscore Prefix so that they can be identified from other local variables names;

12. Avoid naming conflicts with existing .NET Framework namespaces or types;

13. Do not include the parent class name within a property name:

Ex: Good: Customer.Name;               Not good: Customer.CustomerName;

14. When defining a root namespace, use a Product, a Company or a Developer name as the root:

Ex: NorthwindApplication.Utilities;

15. Use Pascal Case for file names;

16. Method name should tell you what it does;

17. A method should do only “one job”. Do not combine multiple jobs in one method even if those jobs have very few lines of code.


protected void SaveCustomerName(string customerName)
   //code here...


Naming Conventions for ASP.NET Controls

In general, naming ASP.NET controls is made using Camel Case naming convention, where the prefix of the name is the abbreviation of the control type name.

Abbreviation ASP.NET Control
btn Button
cb CheckBox
cbl CheckBoxList
ddl DropDownList
fu FileUpload
hdn HiddenField
lnk Hyperlink
img Image
ibtn(btn) ImageButton
lbl Label
lbtn(btn) LinkButton
lb ListBox
lit Literal
mv MultiView
pnl Panel
ph PlaceHolder
rb RadioButton
rbl RadioButtonList
tbl Table
txt TextBox
v View
dtl DataList
dp DataPager
dtv DetailsView
ets EntityDataSource
fv FormView
gv GridView
lds LinqDataSource
lv ListView
ods ObjectDataSource
qe QueryExtender
rpt Repeater
smd SiteMapDataSource
sds SqlDataSource
xds XmlDataSource
cpv CompareValidator
ctv CustomValidator
rv RangeValidator
rev RegularExpressionValidator
rfv RequiredFieldValidator
vs ValidationSummary

Please share your opinion about this post by commenting below.



Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.

  • user

    AUTHOR Mohammad

    Posted on 4:27 pm January 1, 2012.

    Thanks so much …
    This article was really helpful !…

    — Wish you the best —

  • user

    AUTHOR Manoj B. Kalla

    Posted on 11:57 am June 21, 2014.

    Dear Darius Dumitrescu,

    Good article . . All beginners and seniors should follow naming conventions.

    Very Good. . .

    Manoj B. Kalla

  • user

    AUTHOR smi

    Posted on 2:00 pm August 9, 2014.

    Thanks for sharing this


  • user

    AUTHOR Sundar

    Posted on 1:44 am March 22, 2017.

    Thanks for the article and the PDF. It is so useful. Could you suggest any Tool to validate these Coding Standards automatically by Visual Studio? Can tools like StyleCop or Resharper be used?


  • user

    AUTHOR Sanjay Yadav

    Posted on 5:16 am August 22, 2018.

    thank you so much

  • user

    AUTHOR Angel

    Posted on 5:24 pm May 16, 2019.

    It is helpful for my coding

  • user

    AUTHOR Xenon Boi

    Posted on 1:36 pm September 13, 2019.

    Thanks Darius, keep posting quality content!

  • This site uses Akismet to reduce spam. Learn how your comment data is processed.

    View Comments (7) ...