Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

C# Inheritance

Ok. I didn't see a c# group so I'm posting this question about inheritance here.

I'm looking at implementing a base class that will handle all of the common actions linking object details being viewed by a user (i.e. person, organization) with a database (i.e. add, update, delete, etc.). Anyway, is it possible to override a method like "save" in the base class with a "save" method in the derived class that contains all of the business logic and then call the base classes "save" method?

I think that the psuedo code might look like the following

class Base
{
save()
{
some data access logic goes here;
}
}

derivedClass : Base
{
save()
{
business logic unique to this derived class goes here;

base.save();
}
}

Many thanks!

Laurence
[920 byte] By [Hunterlmc] at [2007-11-11 10:27:36]
# 1 Re: C# Inheritance
Yes, that is possible. Are you having a problem doing it?
Phil Weber at 2007-11-11 20:47:46 >