You could make the default constructor private like below:
public class Class1
{
protected Class1(int p1)
{
Debug.WriteLine("RequiredParam " + p1.ToString());
}
private Class1()
{
}
}
public class Class2 : Class1
{
public Class2(int p1) : base(p1)
{
}
}
This won't force a particular constructor signature on the derrived class but it will force the base constructor to be called with the appropriate params.
Tim McBride
This posting is provided "AS IS" with no warranties, and confers no rights.
jthg
Member
207 Points
49 Posts
Abstract Constructors
Mar 28, 2005 10:14 PM|LINK
timmcb
Contributor
2379 Points
471 Posts
Microsoft
Re: Abstract Constructors
Mar 28, 2005 11:43 PM|LINK
You could make the default constructor private like below:
public class Class1
{
protected Class1(int p1)
{
Debug.WriteLine("RequiredParam " + p1.ToString());
}
private Class1()
{
}
}
public class Class2 : Class1
{
public Class2(int p1) : base(p1)
{
}
}
This won't force a particular constructor signature on the derrived class but it will force the base constructor to be called with the appropriate params.
This posting is provided "AS IS" with no warranties, and confers no rights.
JeffreyABeck...
All-Star
16423 Points
3329 Posts
Re: Abstract Constructors
Mar 29, 2005 11:29 AM|LINK
Warning: Code is often uncompiled and possibly started life written on the back of a napkin. Beware typos.