Abstract class using an interface

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
 
N

Nick Malik [Microsoft]

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.
 
A

Abhilash

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
 
A

Abhilash

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top