In this tutorial, we will learn about some of the best practices with C# which we should follow to write better code,

Generally, you need to take care of below things when you want to follow coding standards,

1)Naming Conventions:

Naming conventions refers to how we should declare variables.

There are two types which you need to use for naming conventions:


Naming Convention Table:

- Do Use Meaningful, descriptive words to name variables. Do not use abbreviations.


- Do use PascalCasing for class names and method names.

Public class Employee

- Do use camel casing for method arguments and local variables.

Public class Employee

- Do not use Underscores in identifiers.


- Do prefix interfaces with the letter I.

Public interface IEmployee

- Do declare all member variables at the top of a class, with static variables at the very top.

public class Employee

- Do not suffix enum names with Enum.


2)Optimizing Syntax

- To declare an empty method that only returns a view in the MVC, we should use the expression body.


- To check for null or empty conditions, use the following:


- Do object initialization like below:


- Do use null conditional operator like below:


- Avoiding extra braces is also a practice to get into.


- Below is how to use string interpolation.

Test test=new Test();

- Use of new lightweight switch case introduced in C# 8.

int productSwitch = 1;

Thank You, See you in the next article !!

You can reach out to me here,



Technical Speaker | Computer Engineer | Full Stack Web Developer | ML Enthusiast | * Knowledge Shared = Knowledge² *