473,503 Members | 3,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Partial implementation of interface

Hello friends,
I am new to C#. I have some fundamental doubt. Please, try to answer
it.

1) Ltes say, IFace is an interface which has proto of two methods.
class A implements IFase.

interface IFace
{
void func1(...) {.....}
void func2(...) {.....}
}

class A : IFace
{
void func1(...) {.....}
void func2(...) {.....}
}

class B : A, IFace
{
....
}

Now the question is, in the defination of class B is it neccesory to
implement all two members of IFace. I dont want to change defination
of func1( ) which is from A to B. Or implementation of only one will
solve the problem ?

Sep 21 '07 #1
3 1907
Advait,

Class B, if it does not define anything else, will implement the
interface IFace (you shouldn't need it in the declaration of B, as a matter
of fact).

If you want to provide an implementation of one of the methods defined
in IFace, then you will need to declare the methods in A as virtual, so that
B can override them.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Advait Mohan Raut" <ad***********@gmail.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
Hello friends,
I am new to C#. I have some fundamental doubt. Please, try to answer
it.

1) Ltes say, IFace is an interface which has proto of two methods.
class A implements IFase.

interface IFace
{
void func1(...) {.....}
void func2(...) {.....}
}

class A : IFace
{
void func1(...) {.....}
void func2(...) {.....}
}

class B : A, IFace
{
...
}

Now the question is, in the defination of class B is it neccesory to
implement all two members of IFace. I dont want to change defination
of func1( ) which is from A to B. Or implementation of only one will
solve the problem ?

Sep 21 '07 #2
On Sep 21, 8:24 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Advait,

Class B, if it does not define anything else, will implement the
interface IFace (you shouldn't need it in the declaration of B, as a matter
of fact).

If you want to provide an implementation of one of the methods defined
in IFace, then you will need to declare the methods in A as virtual, so that
B can override them.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
But is it possible that, a method delared in an interface to be
implemented as virtual ?

Sep 21 '07 #3
Advait Mohan Raut <ad***********@gmail.comwrote:
Than you, Nicholas Paldino for the nice information. Actuly I came to
conclusion the one cannot override selected methods of the interface,
because in the offline help of VS 2005 (i.e. C# Reference) they have
stated that 'override' will work only if the base class proto is
either 'override' or 'abstract' or 'virtual' .
But when you implement it in the base class you can make it virtual or
abstract. If you do that, you can override it in the derived class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
6824
by: Paul MG | last post by:
Hi Template partial specialization always seems like a fairly straightforward concept - until I try to do it :). I am trying to implement the input sequence type (from Stroustrup section...
9
4617
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
4
1378
by: Andy Venikov | last post by:
Hi all, is there a way to make certain functions of a class be accessible only by specific class? Like "friend class whatever", but only for a few functions? This could be usefull in a...
9
2501
by: Gomaw Beoyr | last post by:
Two question about the "partial classes" (in the next wersion of ..NET). Question 1 ========== Will partial classes (in the next version of C#) have to be declared "partial" in ALL places. ...
2
1255
by: Billy | last post by:
In .Net 2, when I have created a strongly typed dataset of a SQL table and then 'viewed' the code from the RHM menu. I am taken to the new partial class; as expected, but why do I have a partial...
2
2001
by: PeterKellner | last post by:
I'm trying to understand how asp.net 2.0 ties together the codebehind. I've made a simple page, turned debug on so the *0.cs,*1.cs,*2.cs files don't get erased. My first point of confusion is...
2
5539
by: Joseph Geretz | last post by:
When I create a Form, the VB IDE creates the following files in the following hierarchy: Form1.cs Form1.Designer.cs Form1.resx Both Form1.cs and Form1.Designer.cs are partial implementations...
6
1447
by: satyanarayan sahoo | last post by:
What’s the role of Partial keyword which is bydefault written for a class in 2.0 ? public partial class Form1 : Form
10
1505
by: JDeats | last post by:
So I have a class that spans over two partial classes in code, here's an example (do not read much into this, the code is of no practical use, this is just a simple example of where my confusion...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.