This website utilizes cookies to enhance user experience. Kindly provide your consent for cookie usage. Accept
C# Coding Standard: File Name and Comments

01 July, 2023

READ TIME - 3 MINUTES

Thank you to our sponsors who help keep this blog post free for the reader:

This month's issue is proudly sponsored by Saddam Hossain .NET.

The website is owned by none other than Md. Saddam Hossain, who holds the esteemed title of Senior Software Engineer and is known for his unwavering passion for .NET development . To learn more about Md. Saddam Hossain, You are invited to visit the website for comprehensive details and insights.

Introduction:

I consistently strive to adhere to the highest coding standards and adopt a pragmatic approach in my software development endeavors. Presented below are the file naming conventions and comments guidelines of the C# coding standards that I rigorously apply in my projects.

Files :

The following are the naming conventions and guidance for naming C# files.

Class Files :

File names should follow the PascalCase convention followed by the file extension .cs.

                        LeadSource.cs
                        Opportunity.cs
                        Employee.cs
                        EmployeeRepository.cs
                        EmployeeService.cs
                        EmployeeTypeConfiguration.cs
                        EmployeeDto.cs
                        CreateEmployeeDto.cs
                        UpdateEmployeeDto.cs
                   

Partial Class Files :

Partial class files are files that contain nested classes related to a root file. For example:

                        EmployeeService.cs
                        EmployeeService.Validations.cs
                        EmployeeService.Validations.Add.cs
                        EmployeeService.Exceptions.cs
                   

Each of the previously validations and exceptions is implemented as partial classes, with each one designed to represent distinct facets of a given class within a multi-dimensional context.

Comments :

Comments can only be used to explain what code can't. Whether the code is visible or not. I dont like to write comments unless it's needed.

                        // This is a comment
                   

Copyrights :

Comments highlighting copyrights should follow this pattern:

                        // ---------------------------------------------------------------
                        // Copyright (c) Something about Copyright
                        // Anything we want to mention
                        // ---------------------------------------------------------------
                   


About the Blogs

As a dedicated .NET developer, I maintain a Patreon account where I share exclusive content related to .NET development. There, you will also gain access to the codebase of this blog post. By becoming a Patreon member, you will have the opportunity to explore and learn from my projects firsthand.

If you have found my contributions helpful in any way, I kindly ask you to consider becoming a Patreon supporter. Your support enables me to continue producing high-quality content, empowering developers like yourself to enhance their skills and stay up to date with the latest developments in the .NET ecosystem. Thank you for considering joining my Patreon community!


Recent Posts

Confidently Build Production-Ready CRUD Using N-Layer Architecture

25 February, 2024

Confidently Build Production-Ready CRUD Using Clean Architecture

25 February, 2024


Share This Article On:
An error has occurred. This application may no longer respond until reloaded. Reload 🗙