   Constructor calling a constructor
Quote:When a constructor calls another constructor to help initialize the object it is called a what?This part of of the chapter was very confusing. Using a constructor to initialize a constructor; why and when would you want to do such things?   
public class ClassName{    public readonly string Name;    public ClassName(string myName){   Name = myName;    }    public ClassName(): this("Default Class Name"){}}Things like this where you want to provide sane defaults so users of the class don't have to specify everything every time. You'll also use this when you need to call the base class' constructor.   ;[source language="c#"]public class ClassName{    public readonly string Name;// Constructor// Allows a parameter as type string to be passed into the local variable Name    public ClassName(string myName){   Name = myName;    }// No idea what the below is doing.public ClassName(): this("Default Class Name"){}}Could you please break down the line:    public ClassName(): this("Default Class Name"){}I don't understand what it's doing.;Quote:Original post by fooliosCould you please break down the line:    public ClassName(): this("Default Class Name"){}I don't understand what it's doing.This defines a constructor for ClassName which is public and takes no arguments.(colon)When called it runs through the constructor that takes a string argument with the argument "Default Class Name" specified.It then executes what is within the brackets (nothing in this case).   ;Quote:Original post by TelastynQuote:Original post by fooliosCould you please break down the line:    public ClassName(): this("Default Class Name"){}I don't understand what it's doing.This defines a constructor for ClassName which is public and takes no arguments.(colon)When called it runs through the constructor that takes a string argument with the argument "Default Class Name" specified.It then executes what is within the brackets (nothing in this case).Ok, it's a second constructor. But isn't that class supposed to inherit from some other class? Then this second constructor I thought was trying to use the constructor from the inherited from class. But that's not what's happening I don't think, er I guess. This looks like it's saying from this object but there is no object yet, that's what the constructor is doing isn't it? Creating the object. Sorry, this became very confusing in a hurry.   ;  The following code: public ClassName(): this("Default Class Name"){}is equivalent to having the second constructor like this: public ClassName() {    Name = "Default Class Name"; } All that is happening in the code Telestyn posted is that he makes use of the fact that he already has a constructor that takes a string argument and uses that to construct the object.Actually read the book chapter 15 - P143 for a better explanation.