473,324 Members | 2,254 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,324 software developers and data experts.

OOP concepts - Access level

Hi,
I have the following scenario.

// This namespace is a class library
namespace test
{
Inteface A
{
void method1(...);
}

public abstract class B : A
{
public void method1(...)
{
...
}
}

public class DoIt : B
{
...
}
}

DoIt c = new DoIt(...);
c.method1(...); // can be accessed

From a console Application, I need to access the methods in Class
DoIt, but not the methods inherited from the interface and implemented
in the abstract class B. As they are now, method1 can be accessed
from a console application.

I tried to define these methods as internal or protected, but the
compiler complained with the following error.

'test.B' does not implement interface member 'test.A.method1()'.
'test.B.method1()' is either static, not public, or has the wrong
return type.
Can someone help me solve this out.
Thanks in Advance
Nov 17 '05 #1
4 1146
"Xarky" <be*********@yahoo.com> a écrit dans le message de news:
bc*************************@posting.google.com...
// This namespace is a class library
namespace test
{
Inteface A
{
void method1(...);
}

public abstract class B : A
{
public void method1(...)
{
...
}
}

public class DoIt : B
{
...
}
}

DoIt c = new DoIt(...);
c.method1(...); // can be accessed

From a console Application, I need to access the methods in Class
DoIt, but not the methods inherited from the interface and implemented
in the abstract class B. As they are now, method1 can be accessed
from a console application.

I tried to define these methods as internal or protected, but the
compiler complained with the following error.

'test.B' does not implement interface member 'test.A.method1()'.
'test.B.method1()' is either static, not public, or has the wrong
return type.


Use "explicit interface implementation"

public abstract class B : A
{
void A.method1(...)
{
...
}
}

Then the only way to get at that method is through the interface.

Joanna

--
Joanna Carter
Consultant Software Engineer
Nov 17 '05 #2
Hi,
Can than method1(...) be accessed from class DoIt.
Thanks for your reply

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3
"xarky d_best" <be*********@yahoo.com> a écrit dans le message de news:
eY**************@TK2MSFTNGP10.phx.gbl...
Can than method1(...) be accessed from class DoIt.


Yes, you just need to cast 'this' to A :

public class DoIt : B
{
((B) this).method1();
}

Joanna

--
Joanna Carter (TeamB)

Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
Nov 17 '05 #4
Thanks, problem solved

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5

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

Similar topics

145
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity...
22
by: Ray | last post by:
Hello, I've been learning Python in my sparetime. I'm a Java/C++ programmer by trade. So I've been reading about Python OO, and I have a few questions that I haven't found the answers for :) ...
3
by: Kappa | last post by:
Hello, Can anyone suggest me a good intermediate level C# book that teaches OOP concepts too. I saw Beginning C# Objects: From Concepts to Code by Jacquie Barker, it seems good but I want a...
3
by: Robert | last post by:
I've been working with ASP.NET for about a year and I think I'm on the verge of "getting it." I suspect that if I came to understand a few key concepts it would all come together. One of those "key...
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
20
by: W Karas | last post by:
Would the fear factor for concepts be slightly reduced if, instead of: concept C<typename T> { typename T::S; int T::mem(); int nonmem(); };
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
0
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented...
4
by: Shravani | last post by:
I've been assigned a task to carry out the following exercise using C code: Functional Dependencies & Normalization: a. Specifying & testing Functional Dependencies on a relation...
1
by: Swathika | last post by:
Hi, Sometimes, you never get chance to learn 'Advanced Design Concepts and Real-time Scenarios' from institutes or through book-learning. But, in my blog, I have gathered some of the amazing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.