Inheriting class with private constructor

  • Thread starter Thread starter Michael Carr
  • Start date Start date
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
 
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
 
Back
Top