Comments
In this page:
Comments
C# supports single-line comments with //, multi-line comments with /* */, and XML documentation comments with /// that tools can turn into documentation. Comments are ignored by the compiler and exist purely to explain code to humans. Good comments explain *why*, not what the code already makes obvious.
Note: IDEs like Visual Studio render /// summary comments as IntelliSense tooltips.
Example: Comments
using System;
class Program
{
/// <summary>
/// Adds two integers together.
/// </summary>
static int Add(int a, int b)
{
// simple addition, no overflow checking
return a + b;
}
static void Main(string[] args)
{
/* Call the helper and print the result */
Console.WriteLine(Add(2, 3));
}
}
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: