What is the meaning of CTOR?
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?
It's just shorthand for "constructor" - and it's what the constructor is called in IL, too. For example, open up Reflector and look at a type and you'll see members called .ctor
for the various constructors.
Usually this region should contains the constructors of the class
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;
}
Type "ctor" and press the TAB key twice this will add the default constructor automatically