C# Language Naming Conventions

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

This topic outlines some basic naming conventions used when writing in the C# language. Like all conventions, they are not enforced by the compiler, but will ensure readability between developers.

For comprehensive .NET framework design guidelines, see docs.microsoft.com/dotnet/standard/design-guidelines.

Remarks

Choose easily readable identifier names

For example, a property named HorizontalAlignment is more readable in English than AlignmentHorizontal.

Favor readability over brevity

The property name CanScrollHorizontally is better than ScrollableX (an obscure reference to the X-axis).

Avoid using underscores, hyphens, or any other non-alphanumeric characters.

Do not use Hungarian notation

Hungarian notation is the practice of including a prefix in identifiers to encode some metadata about the parameter, such as the data type of the identifier, e.g. string strName.

Also, avoid using identifiers that conflict with keywords already used within C#.

Abbreviations and acronyms

In general, you should not use abbreviations or acronyms; these make your names less readable. Similarly, it is difficult to know when it is safe to assume that an acronym is widely recognized.



Got any C# Language Question?