Code review in C#: what to check and how to give feedback to beginners

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

Code review in C#: what to check and how to give feedback

\n

Code review is one of the most powerful tools for improving code quality. For beginner C# developers, it often feels stressful: you're afraid your code will be criticized, or you're unsure what exactly to look for in someone else's code. In reality, a good code review is a dialogue, not an exam. In this article, we'll break down what to pay attention to when reviewing C# code (especially in the .NET ecosystem) and how to phrase comments so they help rather than offend.

\n\n

1. What to check in C# code: a reviewer's checklist

\n

When you open a colleague's pull request (PR), your eyes can dart around. To avoid getting lost in details, use a systematic approach. Here are the key areas to check in any C# project.

\n\n

1.1. Architecture and readability

\n

First, assess the big picture. Answer these questions:

\n
    \n
  • Does this code solve the given problem?
  • \n
  • Does it duplicate existing logic (DRY principle)?
  • \n
  • Are the names of classes, methods, and variables clear?
  • \n
\n

Bad:

\n
public void DoStuff(int a, int b)\n{\n    var x = a + b;\n    // ... another 50 lines\n}
\n

Good:

\n
public int CalculateTotalPrice(int basePrice, int taxAmount)\n{\n    return basePrice + taxAmount;\n}
\n

The method and parameter names immediately convey the purpose. This reduces cognitive load on the reader.

\n\n

1.2. Error handling and null safety

\n

C# has a rich type system, but NullReferenceException is a common issue. Check for:

\n
    \n
  • Are null checks used (?. , ??, ??=)?
  • \n
  • Is exception handling (try-catch) present where necessary?
  • \n
  • Are exceptions swallowed in an empty catch block?
  • \n
\n

Example of dangerous code:

\n
var user = GetUserById(id);\nConsole.WriteLine(user.Name); // Error if user == null
\n

Safe version:

\n
var user = GetUserById(id);\nConsole.WriteLine(user?.Name ?? "Guest");
\n\n

1.3. Performance and LINQ

\n

LINQ is convenient but can be inefficient. Check for:

\n
    \n
  • Are there multiple iterations over a collection (e.g., .Where().Select().ToList() on IQueryable)?
  • \n
  • Is Any() used instead of Count() > 0 to check for elements?
  • \n
  • Are there unnecessary materializations (.ToList(), .ToArray()) in the middle of a chain?
  • \n
\n

Bad:

\n
var list = items.Where(x => x.IsActive).ToList();\nvar first = list.FirstOrDefault();
\n

Better:

\n
var first = items.FirstOrDefault(x => x.IsActive);
\n\n

1.4. Asynchrony and Task

\n

In .NET, asynchrony is the standard. Look for:

\n
    \n
  • Is await missing before an asynchronous call?
  • \n
  • Are there blocking calls (.Result, .Wait()) in a synchronous context?
  • \n
  • Is the convention followed: async methods end with Async?
  • \n
\n

Anti-pattern:

\n
var data = GetDataAsync().Result; // May cause deadlock
\n

Correct:

\n
var data = await GetDataAsync();
\n\n

2. How to give feedback: gently but constructively

\n

Even a perfect checklist is useless if your comments sound like criticism. Here are a few rules to make code review useful for everyone.

\n\n

2.1. Use "I" statements and questions

\n

Instead of "You wrote bad code," say "I think this method could be simplified. What do you think?".

\n

Examples of phrasing:

\n
    \n
  • "I'm not su

Blogs

Book Recommendations