locked
what to call this? RRS feed

  • Question


  • Hi,

    I always come across this things in code samples mostly in overloading constructors samples.

    eg.

    Public Time2() : this(0,0,0){}


    :this(0,0,0){} what to call this? is it the same as resolution operator ::


    Thank you

    Tuesday, March 11, 2008 8:54 AM

Answers

  • Well, according to section 17.10.1 of ECMA 334 (4th ed) it is a "instance constructor initializer" of the type itself - i.e. before running the body (the bit between the braces {}), it first runs the nominated constructor, picking it via the standard overloading rules. If it were ": base(0,0,0) {}" then it would be picking a specific constructor from the base class.

     

    In reality, I might simply refer to it as constructor chaining or similar.

    Tuesday, March 11, 2008 9:13 AM