Abstract class using an interface

  • Thread starter Thread starter Abhilash
  • Start date Start date
A

Abhilash

hi,

My requirement is that there is an interface and want to implement some
of the methods of this interface and the rest will be implement by the
classes which derive from it

Ex

Interface I
{
method m1();
method m2();
}

abstract class A implement I
{
sealed method m1()
{
// Implement something that every body will use and cannot be
changed in sub class
}
abstract method m2();
}

class B :A
{
method m2()
{
//user does his own work
}

}

How can this be acheived?

bye
Abhilash
 
why use an interface at all? If you have a base method, why not just use a
virtual base class?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
I see the point.. I am using abstract currently which i think is the
same as what you suggesting me to do. But i have to use two abstract
classes because only in the second one am i able to specify the method
as sealed
 
Well yes... In fact the solution i have taken because i couldnt do the
above was to use two abstract classes. I had to use 2 because only in
the second one was i able to specify the coding of my sealed method.

bye
Abhilash
 
Back
Top