What is the meaning of CTOR?

前端 未结 4 995
心在旅途
心在旅途 2021-01-30 12:08

In a lot of C# files I save regions tags(?) that are named CTOR or ctor. What\'s the meaning of ctor? Why is such a region called ctor?

4条回答
  •  感情败类
    2021-01-30 12:30

    To expand a little more, there are two kinds of constructors: instance initializers (.ctor), type initializers (.cctor). Build the code below, and explore the IL code in ildasm.exe. You will notice that the static field 'b' will be initialized through .cctor() whereas the instance field will be initialized through .ctor()

    internal sealed class CtorExplorer
    {
       protected int a = 0;
       protected static int b = 0;
    }
    

提交回复
热议问题