471,317 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Interface and Inheritance

Hi all
I have a calss that derived from IList.
you know that I have to implement methods of IList and make them public.
is it possible to make them private?/
becuase I saw for example in DataTable class that has derived from
IListSource but it hasen't made them public..
I got mixed up about that..
thanks in advance
Dec 27 '05 #1
5 933
You can implement the interface 'explicitly'. That way, the IList properties
won't appear unless the IList prefix is entered first.
Dec 27 '05 #2
could u show me an example??
"David Veeneman" <da****@nospam.com> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
You can implement the interface 'explicitly'. That way, the IList properties won't appear unless the IList prefix is entered first.

Dec 27 '05 #3
Hi,

If you are using VS it's very easy, all you have to do is write down the
interface and you will be presented with the option of pressing TAB to
implement the stubs methods, now they are declared implicitely (not with the
prefix IList ) before, so you will have to edit them. When you do so you
will have to remove the public as they are public already

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"perspolis" <re*****@hotmail.com> wrote in message
news:OU*************@TK2MSFTNGP14.phx.gbl...
could u show me an example??
"David Veeneman" <da****@nospam.com> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
You can implement the interface 'explicitly'. That way, the IList

properties
won't appear unless the IList prefix is entered first.


Dec 27 '05 #4
perspolis wrote:
could u show me an example??
"David Veeneman" <da****@nospam.com> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
You can implement the interface 'explicitly'. That way, the IList

properties
won't appear unless the IList prefix is entered first.

You have:

public class MyList: IList
{
<...>
public int Add(object o)
{ whatever }
<...>
}

---- You change it to:
public class MyList: IList
{
<...>
int IList.Add(object o)
{ whatever }
<...>
}

This will hide function Add. Just do it for the rest of IList(including
ICollection and IEnumerable) functions.

Hope it helps,
MuZZy
Dec 27 '05 #5
"perspolis" <re*****@hotmail.com> a écrit dans le message de news:
OU*************@TK2MSFTNGP14.phx.gbl...

| could u show me an example??

public interface IThing
{
void DoSomething();
}

public class Thing : IThing
{
void IThing.DoSomething()
{
...
}
}

the DoSomething method is marked as private internally and can only be
accessed through an interface reference to a Thing object through IThing :

{
Thing t = new Thing();

t.DoSomething() // this won't compile, DoSomething() is private

IThing it = (IThing) t;
it.DoSomething(); // this works through the interface only
}

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Dec 27 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Tom Evans | last post: by
4 posts views Thread by Roy Pereira | last post: by
4 posts views Thread by christopher diggins | last post: by
21 posts views Thread by Helge Jensen | last post: by
7 posts views Thread by Hazz | last post: by
10 posts views Thread by Brett | last post: by
6 posts views Thread by John Salerno | last post: by
12 posts views Thread by Meya-awe | last post: by
4 posts views Thread by Raja Chandrasekaran | last post: by
52 posts views Thread by Ben Voigt [C++ MVP] | last post: by
reply views Thread by rosydwin | last post: by

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.