473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 975
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Tom Evans | last post by:
My basic question: If I have a specific interface which I know is going to be implemented by a number of classes, but there is no implementation commonality between them, what is the preferred...
4
by: Roy Pereira | last post by:
I have an application that is composed of a set of "Content" dlls and a viewer application. The viewer calls a standard set of functions that are present in all the dlls. I maintain this by...
4
by: christopher diggins | last post by:
A feature that I find signficantly missing in C# is the ability to write functions in interfaces that can call other functions of the interface. Given an interface ISomeInteface the only way we can...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
7
by: Hazz | last post by:
Are there any good references/articles/books which provide clarity toward my insecurity still on deciding how to model a complex system? I still feel uncomfortable with my understanding, even...
10
by: Brett | last post by:
I'm still trying to figure out concrete reasons to use one over the other. I understand the abstract class can have implementation in its methods and derived classes can only inherit one abstract...
6
by: John Salerno | last post by:
I understand how they work (basically), but I think maybe the examples I'm reading are too elementary to really show their value. Here's one from Programming C#: #region Using directives ...
12
by: Meya-awe | last post by:
I am puzzled, what is the purpose of an interface? How does it work, what i mean is how does the compiler treats this? Why when we talk about separating user interface from business logic, an...
4
by: Raja Chandrasekaran | last post by:
Hai friends, I really wonder, If the interface does not have any definition, Y do we need to use interface. You can then only we can use Multiple inheritance. I really cant understand, Just for...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.