Special chars in C# comments

L

LellD

It seems not unusual for me that I have special chars like
< (less than) or > (greater than) in C# comments,
especially in <code> sections. For instance,
<code> if(a<b) c=3; </code> should be a valid comment, but
the '<' in the if statement is treated as beginning of a
new XML token and leads to a compiler warning.
Do you have any idea how I can use these characters in C#
comments, without beeing interpreted as XML tokens?

Thanks,
Dirk
 
J

Jon Skeet [C# MVP]

LellD said:
It seems not unusual for me that I have special chars like
< (less than) or > (greater than) in C# comments,
especially in <code> sections. For instance,
<code> if(a<b) c=3; </code> should be a valid comment, but
the '<' in the if statement is treated as beginning of a
new XML token and leads to a compiler warning.
Do you have any idea how I can use these characters in C#
comments, without beeing interpreted as XML tokens?

Use &lt; instead of <, &gt; instead of >.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top