Inheriting class with private constructor

M

Michael Carr

Does anybody know how to inherit from a class with a private constructor? I
am trying to inherit from DataRow as follows:

public class MyDataRow : DataRow
{
private MyDataRow()
{
}
}

When I compile this, I get "No overload for method 'DataRow' takes '0'
arguments"

Any ideas?

Thank you,
Michael Carr
 
N

Natty Gur

Hi,
Getting “Could not find any resources “error while using some resource
files to make the internationalization of a ASP.NET application

1) You get that error because DataRow constructor demand parameter that
you didn’t supply :

private MyDataRow(System.Data.DataRowBuilder builder):base(builder)
{
}

2) You can’t inherit from class with private constructor. if you want
your class to be accessible only for inherit class mark your constructor
as protected.

public class MyDataRow : System.Data.DataRow
{

protected MyDataRow(System.Data.DataRowBuilder builder):base(builder)
{
}
}
public class aa : MyDataRow
{
public aa(System.Data.DataRowBuilder builder):base(builder)
{

}
}

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top