D
DC
I have created the following abstract class:
public abstract class BaseC
{
protected int _ID;
protected string _name;
protected abstract DataTable GetData(int ID);
// intended to hit data access layer
protected static string GetValue(int ID)
{
DataTable DT = new DataTable();
DT = GetData(ID);
if (DT.Rows.Count == 1)
{
return DT.Rows[0]["name"].ToString();
}
else
{
return "";
}
}
}
I have also created the following derived class
public class DerivedC : BaseC
{
protected override DataTable GetFields(int ID)
{
DAL.List listDAL = new DAL.List();
listDAL.ID = ID
return listDAL.SelectOne();
}
}
As you can see the SetFields method in BaseC will be
inherited and the GetFields method will be overridden. I
am getting the following error:
"An object reference for the nonstatic field, method, or
property 'NameSpace.BaseC.GetFields(int)"
The GetFields(int) method is called from SetFieds(int) in
BaseC; however, the GetFields(int) method will be
overridden by the derived class so that the DAL can be
accessed.
Does anybody have any ideas on how to fix this?
public abstract class BaseC
{
protected int _ID;
protected string _name;
protected abstract DataTable GetData(int ID);
// intended to hit data access layer
protected static string GetValue(int ID)
{
DataTable DT = new DataTable();
DT = GetData(ID);
if (DT.Rows.Count == 1)
{
return DT.Rows[0]["name"].ToString();
}
else
{
return "";
}
}
}
I have also created the following derived class
public class DerivedC : BaseC
{
protected override DataTable GetFields(int ID)
{
DAL.List listDAL = new DAL.List();
listDAL.ID = ID
return listDAL.SelectOne();
}
}
As you can see the SetFields method in BaseC will be
inherited and the GetFields method will be overridden. I
am getting the following error:
"An object reference for the nonstatic field, method, or
property 'NameSpace.BaseC.GetFields(int)"
The GetFields(int) method is called from SetFieds(int) in
BaseC; however, the GetFields(int) method will be
overridden by the derived class so that the DAL can be
accessed.
Does anybody have any ideas on how to fix this?