This web page has a good explanation of all the issues: Constructors
For example, what I hadn't really considered is that:
public class MySimpleClass
{
public MySimpleClass()
{
}
}
is converted by the compiler into:
public class MySimpleClass
{
public MySimpleClass() : base()
{
}
}
which makes a bunch of stuff easier to understand.Similarly 'this' can be used to invoke constructors in the same class:
public class MySimpleClass : MyBaseClass
{
public MySimpleClass() : this(5)
{
}
public MySimpleClass(int x) : base(x)
{
}
}
No comments:
Post a Comment