c# - When inheriting from a framework control, should I call the base constructor? -
i'm inheriting listbox. need explicitly call base constructor?
public class mylistbox : listbox { public mylistbox() : base() { } // or public mylistbox() { } }
the 2 options listed compile identical code.
the reason include : base() explicitly denote calling base classes default constructor instead of other constructor, design. if left off, happens automatically. such, optional.
however, if want use constructor other parameterless constructor of base class, have explicitly state this, ie:
public mylistbox() : base("foo") { } this explicitly use constructor accepted string argument.
Comments
Post a Comment