Re: Novice question about inherited constructors



Thank you. I am actually trying to figure out why a TreeView works when
nodes are constructed using the TreeNode class but do not work when using a
class derived from TreeNode.

What is the difference between

public class TreeNode
{
public TreeNode()
{
}

}

and

public class B : TreeNode
{
public B : base()
{}

}

?

Why does an index go out of range in LoadViewState with the later.


"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1ea4babf6ad3731798d07e@xxxxxxxxxxxxxxxxxxxxxxx
David <Contributor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
How is
public class A
{
public A(){}
}
different from
public class B : A
{
public B() : base()
{}
}

The first declares a type which derives from System.Object
(implicitly). The second declares a type which derives from A. Both
declare a public parameterless constructor which calls (implicitly in
the first case) the parameterless constructor in the base class.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


.



Relevant Pages

  • Re: TreePath
    ... So it seems almost an oversight to me that TreePath doesn't ... have a constructor that takes a single TreeNode, ... TreeNode implementations (DefaultMutableTreeNode, ... the output of DefaultTreeModel.getPathToRootcan be used in a TreePath constructor. ...
    (comp.lang.java.gui)
  • Re: TreePath
    ... So it seems almost an oversight to me that TreePath doesn't ... have a constructor that takes a single TreeNode, or that any of the known ... It has the getPath method returning an array of ...
    (comp.lang.java.gui)