Here are the main reasons why commented code is a code smell:
If some code must be conditionally compiled, then the preprocessor's #if should be used, as in:
#if DEBUG Console.WriteLine("Debug mode is activated!"); #endif
The following code snippet illustrates this rule:
using System; class Program { // This line is fine, but the following is not //int Id = 0; /* The following line is bad void Test() { int dirId = this.Id++; } No violation on the following line, because there is at most one violation per comment MyMethod(); */ static void Main(string[] args) { } }