'What is the meaning of CTOR?
In a lot of C# files I see regions tags(?) that are named CTOR or ctor. What's the meaning of ctor? Why is such a region called ctor?
Solution 1:[1]
Usually this region should contains the constructors of the class
Solution 2:[2]
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;
}
Solution 3:[3]
Type "ctor" and press the TAB key twice this will add the default constructor automatically
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ghyath Serhal |
| Solution 2 | Alfie |
| Solution 3 | teo van kot |
