Why is the .ctor() created when I compile C# code into IL?

前端 未结 5 701
醉梦人生
醉梦人生 2021-01-04 02:15

With this simple C# code, I run csc hello.cs; ildasm /out=hello.txt hello.exe.

class Hello
{
    public static void Main()
    {
        System.         


        
5条回答
  •  滥情空心
    2021-01-04 02:34

    A class for which you don't define a constructor gets an implicit public default constructor.

    public MyClass()
      :base()
    {
    }
    

    This only works if the base class has an accessible parameterless constructor.

提交回复
热议问题