|
Thursday, 05 March 2009
|
|
HTML clipboard
- in a constructor
- in an instance method
- instance property accessor
Attemps at using the keyword base in a static method will result in a
error.
Example:
This brief example displays the concept of calling the base classes method even
though it has been overridden in the derived class!
| |
<%@ Page language="c#" %> |
<script language="C#" runat="server">
public class CSharp
{
public virtual string GetMessage()
{
return "<br>All your base are belong to us!";
}
}
public class Friends: CSharp
{
public override string GetMessage()
{
return base.GetMessage();
}
}
public void Page_Load(object sender, EventArgs e)
{
Friends CSF = new Friends();
Response.Write(CSF.GetMessage());
}
</script>
|
You can call a base classes contructor from within a derived classes
contructor as follows (below is the derived classes constructor):
public DerivedClassesConstructor() : base()
{
}
|
|