我需要为Items创建一个类吗?我打算用Abstract Class创建它。因此,Stores,Purchase,BOM等其他类可以使用Items。我需要在Abstact类中创建一些方法,比如ItemName,ItemDesc,ItemMake等,这样我就可以在任何其他类中使用它,如何实现呢?
答案 0 :(得分:1)
看看这篇MSDN文章,解释如何创建抽象类。然后从中创建派生类。
答案 1 :(得分:1)
您应该查看MSDN以获取更多详细信息,但这是一个简单的模拟:
public abstract class BaseItem
{
public int ItemId{get;set;}
public string ItemName{get;set;}
/* Add additional properties */
public void PublichSharedMethod()
{
/* This method will be publicly available to all derived members and external activators */
}
protected void PortectedMethod()
{
/* This method will be available only to derived classes */
}
protected virtual ProtectedBaseImplementation()
{
/* This method will be available only to derived classes, and they can override its behavior */
}
public abstract void RequriesImplementation();
/* This method is publicly available to all, but all derived classes must implement it */
}