Using ildasm and a C# program e.g.
static void Main(string[] args) { }
gives:
.method private hidebysig static void Main(string[] args) cil managed { .entrypoint // Code size 2 (0x2) .maxstack 8 IL_0000: nop IL_0001: ret } // end of method Program::Main
What does the hidebysig construct do?
From ECMA 335, section 8.10.4 of partition 1:
(It’s not immediately clear from that, but
hidebysigmeans ‘hide by name-and-signature’.)Also in section 15.4.2.2 of partition 2:
As an example, suppose you have:
That’s valid, because
Bar(string)doesn’t hideBar(), because the C# compiler useshidebysig. If it used ‘hide by name’ semantics, you wouldn’t be able to callBar()at all on a reference of typeDerived, although you could still cast it to Base and call it that way.EDIT: I’ve just tried this by compiling the above code to a DLL, ildasming it, removing
hidebysigforBar()andBar(string), ilasming it again, then trying to callBar()from other code:However:
(No compilation problems.)