Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

A delimited comment in C# is an input element that instructs the compiler to ignore a specific sequence of characters enclosed within a defined starting and ending boundary. According to the C# Language Specification, comments and their delimiters are not classified as lexical tokens; instead, they act as separators between actual tokens. The syntax utilizes the forward-slash and asterisk characters as delimiters. The comment begins with the /* sequence and terminates at the first occurrence of the */ sequence.
/* 
   This text is enclosed in a delimited comment.
   The C# compiler ignores everything between the delimiters.
*/
Because the comment is explicitly bounded, it can be inserted inline within executable code. The lexer processes the delimited comment similarly to whitespace, meaning it can separate tokens but cannot split a single token (such as a keyword or identifier).
int /* inline delimited comment */ recordCount = 100;

Lexical Processing and Nesting

During the lexical analysis phase of compilation, the C# lexer scans for the /* sequence. Once found, it consumes all subsequent characters without evaluating them until it encounters the exact */ sequence. A critical technical constraint of C# delimited comments is that they cannot be nested. The lexer does not maintain a stack of opening delimiters; it simply terminates the comment block at the very first closing delimiter it finds. Any /* sequence located inside an active delimited comment is treated as standard ignored text, not as a new comment boundary.
/* 
   Outer comment begins here.
   /* 
      This inner sequence does not start a new comment block.
      The entire comment will end at the first closing sequence below.
   */ 
int x = 5; // This is parsed as standard C# code because the comment terminated above.
Master C# with Deep Grasping Methodology!Learn More