Search code examples
.netsyntaxcommentscilil

Is there such a thing as a comment in IL?


I realize nobody just sits down and develops software in straight IL (do they?). But suppose you want to share a snippet of IL code (as output by, e.g., the C# compiler) with someone else for discussion, and furthermore you want to annotate it with a few comments. Is there an actual syntax for comments in IL so that you could do this without making the text invalid as IL? Not really a big deal, just curious.


Solution

  • Yes, you can use // and /* ... */ just like in C#.

    I can't find any reference to it in ECMA-335, but this IL guide includes:

    The first two lines (started with //) are the comments. In ILAsm, you can comment in the same way as that in C# or C++. To comment multiple lines or the part of line, you can also use /* ... */ block as well.