interface classes
i"m new to interfaces
i have this code example :
public class DALF
{
public class Car
{
public int AddEdit(int? CarId, string Name)
{
....
}
public DataTable Get(int? CarId)
{
.....
return CarD.Get(obj);
}
}
public class Worker
{
public static int AddEdit(int? WorkerId, string Name)
{
....
}
public DataTable Get(int? WorkerId)
{
.....
开发者_如何学Go return carD.Get(obj);
}
}
}
How can i implement this calss as interface?
No offense, but I would suggest you read a few basic tutorials about OO. It sounds to me that you do not fully understand what an interface does or how inheritance works.
DISCLAIMER:
I know that this answer is not a solution to the question at hand. But our business here is to help people. And answering this question won't help avi, since his question (as far as I can understand) is based on a poor understanding of basic concepts of OO.
public interface IYourName
{
int AddEdit(int? id, string name);
DataTable Get(int? id);
}
public class DALF
{
public class Car : IYourName
{
public int AddEdit(int? CarId, string Name)
{
//....
}
public DataTable Get(int? CarId)
{
//.....
return CarD.Get(obj);
}
}
public class Worker : IYourName
{
public int AddEdit(int? WorkerId, string Name)
{
//....
}
public DataTable Get(int? WorkerId)
{
//.....
return carD.Get(obj);
}
}
}
Are you sure you only have static classes and methods? Interfaces are not relevent in this case.
More info here: Why Doesn't C# Allow Static Methods to Implement an Interface?
精彩评论