Calling All Constructors

March 30, 2005

I wanted to change some code I had written last week so that an ::google(“overloaded constructor”, “overloaded constructor”):: would call the default constructor. This is usefull when you have to perform an initialization to a class member no matter what constructor is called during the class’ initialization. I faintly remembered Java’s Base and SuperBase(?) syntax and tried several combinations of this and base keywords. Nothing seemed to work… That’s when I came across this post which gave me the answer:

public class PostList
{

private ArrayList m_Posts;

#region Constructor

public PostList()
{
m_Posts = new ArrayList();
}

public PostList(XmlNode posts): this()
{
PopulatePosts(posts);
}

#endregion
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous Post
«