The abstract attribute declaration does not provide the Implementation of the attribute accessors. It only declares that the class supports attributes, and leaves the accessors implementation to the derived class.
The following example shows how to implement abstract attributes inherited from the base class.
C #
Public abstract class base
{
// name is a abstract property
public abstract string Name
{
get;
set;
}
}
public class Child: Base
{
private string m_Name;
//override abstract property
public override double Name
{
get
{
return m_Name;
}
set
{
m_Name = value;
}
}
}
VB.Net
Public MustInherit Class Base
// name is a abstract property
Public MustOverride Name() As String
End Class
Public class Child
Inherits Base
Private m_Name As String
//override abstract property
public Overrides Property Name() As String
Get
Return m_Name;
End Get
Set
m_Name = value;
End Set
End Property
End Class
When declaring abstract attributes (such as name in this example), specify which attributes are available for accessors and do not implement them.