Click here to Skip to main content
15,389,877 members
Articles / Programming Languages / C# 4.0
Posted 30 May 2013


361 bookmarked

Code Review Checklist and Guidelines for C# Developers

Rate me:
Please Sign up or sign in to vote.
4.84/5 (141 votes)
23 Nov 2016CPOL8 min read
This is a general code review checklist and guidelines for C# developers, which will serve as a reference point for development.


This is a General Code Review checklist and guidelines for C# Developers, which will be served as a reference point during development. This is to ensure that most of the General coding guidelines have been taken care of, while coding. Especially, it will be very helpful for entry-level and less experienced developers (0 to 3 years exp.) to refer this checklist until it becomes a habitual practice for them.



  1. Make sure that there shouldn't be any project warnings.
  2. It will be much better if Code Analysis is performed on a project (with all Microsoft Rules enabled) and then remove the warnings.
  3. All unused usings need to be removed. Code cleanup for unnecessary code is always a good practice.


  4. 'null' check needs to be performed wherever applicable to avoid the Null Reference Exception at runtime.
  5. Naming conventions to be followed always. Generally for variables/parameters, follow Camel casing and for method names and class names, follow Pascal casing.


  6. Make sure that you are aware of SOLID principles.

    Definition from Wikipedia: In computer programming, SOLID (Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) is a mnemonic acronym introduced by Michael Feathers for the "first five principles" identified by Robert C. Martin[1][2] in the early 2000s[3] that stands for five basic principles of object-oriented programming and design. The principles when applied together intend to make it more likely that a programmer will create a system that is easy to maintain and extend over time.[3] The principles of SOLID are guidelines that can be applied while working on software to remove code smells by causing the programmer to refactor the software's source code until it is both legible and extensible. It is typically used with test-driven development, and is part of an overall strategy of agile and adaptive programming.


  7. Code Reusability: Extract a method if the same piece of code is being used more than once or you expect it to be used in future. Make some generic methods for repetitive task and put them in a related class so that other developers start using them once you intimate them. Develop user controls for common functionality so that they can be reused across the project.


  8. Code Consistency: Let's say that an Int32 type is coded as int and String type is coded as string, then they should be coded in that same fashion across the application. But not like sometimes int and sometimes as Int32.
  9. Code Readability: Should be maintained so that other developers understand your code easily.


  10. Disposing of Unmanaged Resources like File I/O, Network resources, etc. They have to be disposed of once their usage is completed. Use usings block for unmanaged code, if you want to automatically handle the disposing of objects once they are out of scope.


  11. Proper implementation of Exception Handling (try/catch and finally blocks) and logging of exceptions.


  12. Making sure that methods have less number of lines of code. Not more than 30 to 40 lines.
  13. Timely check-in/check-out of files/pages at source control (like TFS).


  14. Peer code reviews. Swap your code files/pages with your colleagues to perform internal code reviews.
  15. Unit Testing. Write developer test cases and perform unit testing to make sure that basic level of testing is done before it goes to QA testing.


  16. Avoid nested for/foreach loops and nested if conditions as much as possible.
  17. Use anonymous types if code is going to be used only once.


  18. Try using LINQ queries and Lambda expressions to improve Readability.


  19. Proper usage of var, object, and dynamic keywords. They have some similarities due to which most of the developers are confused or don’t know much about them and hence they use them interchangeably, which shouldn't be the case.


  20. Use access specifiers (private, public, protected, internal, protected internal) as per the scope need of a method, a class, or a variable. Let's say if a class is meant to be used only within the assembly, then it is enough to mark the class as internal only.


  21. Use interfaces wherever needed to maintain decoupling. Some design patterns came into existence due to the usage of interfaces.


  22. Mark a class as sealed or static or abstract as per its usage and your need.


  23. Use a Stringbuilder instead of string if multiple concatenations are required, to save heap memory.
  24. Check whether any unreachable code exists and modify the code if it exists.
  25. Write comments on top of all methods to describe their usage and expected input types and return type information.
  26. Use a tool like Silverlight Spy to check and manipulate rendered XAML in Runtime of a Silverlight application to improve productivity. This saves lot of back & forth time between Design & Run views of the XAML.
  27. Use fiddler tool to check the HTTP/network traffic and bandwidth information to trace the performance of web application and services.
  28. Use WCFTestClient.exe tool if you want to verify the service methods out of the Visual Studio or by attaching its process to Visual Studio for debugging purposes.
  29. Use constants and readonly wherever applicable.


  30. Avoid type casting and type conversions as much as possible; because it is a performance penalty.


  31. Override ToString (from Object class) method for the types which you want to provide with custom information.


  32. Avoid straightaway copy/pasting of code from other sources. It is always recommended to hand write the code even though if you are referring to the code from some sources. By this, you will get good practice of writing the code yourself and also you will understand the proper usage of that code; finally you will never forget it.
  33. Always make it a practice to read books/articles, upgrade and follow the Best Practices and Guidelines by industry experts like Microsoft experts and well-known authors like Martin Fowler, Kent Beck, Jeffrey Ritcher, Ward Cunningham, Scott Hanselman, Scott Guthrie, Donald E Knuth.
  34. Verify whether your code have any memory leakages. If yes, make sure that they have been fixed.


  35. Try attending technical seminars by experts to be in touch with the latest software trends and technologies and best practices.
  36. Understand thoroughly the OOPs concepts and try implementing it in your code.
  37. Get to know about your project design and architecture to better understand the flow of your application as a whole.
  38. Take necessary steps to block and avoid any cross scripting attacks, SQL injection, and other security holes.
  39. Always encrypt (by using good encryption algorithms) secret/sensitive information like passwords while saving to database and connection strings stored in web.config file(s) to avoid manipulation by unauthorized users.
  40. Avoid using default keyword for the known types (primitive types) like int, decimal, bool, etc. Most of the times, it should be used in case of Generic types (T) as we may not be sure whether the type is a value type or reference type.


  41. Usage of 'out' and 'ref' keywords be avoided as recommended by Microsoft (in the Code analysis Rules and guidelines). These keywords are used to pass parameters by reference. Note that 'ref' parameter should be initialized in the calling method before passing to the called method but for 'out' parameter this is not mandatory.


Another Article Reference on Review Guidelines

Today, I came across another article related to Code review guidelines on Code project and I find it very interesting. The author has given a perfect explanation about what is code review and what needs to be taken care of being a developer or being a reviewer, the importance of code reviews, tips for developers and reviewers, and review checklist. I recommend my readers to go through it once.

Article link:


1. Added another article reference on review guidelines and conclusion part.

2. Added a download link as a PDF of this article contents.

3. Added one more point to the list about the usage of 'out' and 'ref' keywords.


I welcome feedbacks, queries, and suggestions from the readers so that I can improve it further and developers should get some benefit out of it. My aim is to gradually make it a complete code review guideline especially for C# developers and in the next version, I'm planning to add supporting code examples and screenshots for much better understanding purposes.

Disclaimer: This document does not guarantee that all the mentioned guidelines and practices are applicable as of today. Therefore it is always recommended to check MSDN, discuss with experts and check other portals for the current and modified guidelines and practices. Also, note that some of the provided reference links might not work.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mohammed Hameed
Software Developer (Senior) Infor Global Solutions
India India
SSE @ Infor.
.NET Development.

Email: (or)

Comments and Discussions

GeneralRe: My vote of 5 Pin
Mohammed Hameed6-Jun-13 18:44
professionalMohammed Hameed6-Jun-13 18:44 
QuestionMy vote of 5 Pin
Cesar Santos6-Jun-13 10:40
professionalCesar Santos6-Jun-13 10:40 
AnswerRe: My vote of 5 Pin
Mohammed Hameed6-Jun-13 18:44
professionalMohammed Hameed6-Jun-13 18:44 
GeneralMy vote of 5 Pin
pwnstar6-Jun-13 5:14
Memberpwnstar6-Jun-13 5:14 
GeneralRe: My vote of 5 Pin
Mohammed Hameed6-Jun-13 18:44
professionalMohammed Hameed6-Jun-13 18:44 
GeneralRe: My vote of 5 Pin
pwnstar7-Jun-13 2:17
Memberpwnstar7-Jun-13 2:17 
GeneralRe: My vote of 5 Pin
Mohammed Hameed7-Jun-13 2:36
professionalMohammed Hameed7-Jun-13 2:36 
GeneralMy vote of 5 Pin
Faisal(mfrony)5-Jun-13 21:43
MemberFaisal(mfrony)5-Jun-13 21:43 
Nice Article
GeneralRe: My vote of 5 Pin
Mohammed Hameed6-Jun-13 18:41
professionalMohammed Hameed6-Jun-13 18:41 
GeneralSome Links updated. Pin
Mohammed Hameed5-Jun-13 21:10
professionalMohammed Hameed5-Jun-13 21:10 
GeneralMy vote of 5 Pin
bfc924065-Jun-13 20:50
Memberbfc924065-Jun-13 20:50 
GeneralRe: My vote of 5 Pin
Mohammed Hameed6-Jun-13 18:41
professionalMohammed Hameed6-Jun-13 18:41 
QuestionVery useful! Pin
nonintanon5-Jun-13 19:35
Membernonintanon5-Jun-13 19:35 
AnswerRe: Very useful! Pin
Mohammed Hameed5-Jun-13 19:57
professionalMohammed Hameed5-Jun-13 19:57 
GeneralRe: Very useful! Pin
nonintanon5-Jun-13 21:02
Membernonintanon5-Jun-13 21:02 
GeneralRe: Very useful! Pin
Mohammed Hameed5-Jun-13 21:06
professionalMohammed Hameed5-Jun-13 21:06 
GeneralRe: Very useful! Pin
nonintanon5-Jun-13 22:32
Membernonintanon5-Jun-13 22:32 
GeneralRe: Very useful! Pin
Mohammed Hameed6-Jun-13 0:19
professionalMohammed Hameed6-Jun-13 0:19 
GeneralRe: Very useful! Pin
Mohammed Hameed19-Jun-13 3:07
professionalMohammed Hameed19-Jun-13 3:07 
GeneralMy vote of 4 Pin
Rockstar_5-Jun-13 19:14
professionalRockstar_5-Jun-13 19:14 
GeneralRe: My vote of 4 Pin
Mohammed Hameed5-Jun-13 19:24
professionalMohammed Hameed5-Jun-13 19:24 
GeneralMy vote of 1 Pin
Global Analyser5-Jun-13 19:12
MemberGlobal Analyser5-Jun-13 19:12 
GeneralRe: My vote of 1 Pin
Mohammed Hameed5-Jun-13 19:30
professionalMohammed Hameed5-Jun-13 19:30 
GeneralRe: My vote of 1 Pin
Mohammed Hameed5-Jun-13 21:05
professionalMohammed Hameed5-Jun-13 21:05 
GeneralRe: My vote of 1 Pin
Global Analyser5-Jun-13 22:09
MemberGlobal Analyser5-Jun-13 22:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.