473,473 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Accessibility modifier question

I'm a little confused about an accessibility issue I'm encountering. Maybe
someone can shed some light on it for me.

I have an abstract class AClass1, an abstract class AClass2 that inherits
from AClass1, a regular class 'Class3' that inherits from AClass2 and a
regular class Class4 that inherits from AClass1.
Summarized:
AClass1 -> AClass2 -> Class3
AClass1 ->Class4

Any class that derives from either AClass1 or AClass2 must provide a static
method GetPath(), the implementation of which is only known to the derived
class (Class3 and Class4).
Given this requirement, I thought I should create an abstract GetPath()
method in AClass1, and override it in the derived class Class3 and Class4.
In AClass1 I declared GetPath() as protected abstract, so that only derived
Class3 and Class4 can access it.
However, in Class3 I cannot create GetPath() as public static override
(compiler error), only protected override. However, protected override means
I cannot access the function from outside as Class3.GetPath(), in fact I
cannot access it at all.

I'm probably not understanding a basic concept here... I sure would
appreciate some help.

Thanks in advance!

-- Hans De Schrijver
Nov 16 '05 #1
2 1165
Hans De Schrijver <ha**@punctualgraphics.com> wrote:
I'm a little confused about an accessibility issue I'm encountering. Maybe
someone can shed some light on it for me.

I have an abstract class AClass1, an abstract class AClass2 that inherits
from AClass1, a regular class 'Class3' that inherits from AClass2 and a
regular class Class4 that inherits from AClass1.
Summarized:
AClass1 -> AClass2 -> Class3
AClass1 ->Class4

Any class that derives from either AClass1 or AClass2 must provide a static
method GetPath(), the implementation of which is only known to the derived
class (Class3 and Class4).


That's your problem to start with - static methods aren't really
inherited (and aren't polymorphic) so there's no such concept of a
static abstract method, which is what it sounds like you want.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hans,

There is no abstract static concept here.
You might try using reflection to simulate it.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Hans De Schrijver" <ha**@punctualgraphics.com> wrote in message
news:M9*******************@fe2.texas.rr.com...
I'm a little confused about an accessibility issue I'm encountering. Maybe
someone can shed some light on it for me.

I have an abstract class AClass1, an abstract class AClass2 that inherits
from AClass1, a regular class 'Class3' that inherits from AClass2 and a
regular class Class4 that inherits from AClass1.
Summarized:
AClass1 -> AClass2 -> Class3
AClass1 ->Class4

Any class that derives from either AClass1 or AClass2 must provide a static method GetPath(), the implementation of which is only known to the derived
class (Class3 and Class4).
Given this requirement, I thought I should create an abstract GetPath()
method in AClass1, and override it in the derived class Class3 and Class4.
In AClass1 I declared GetPath() as protected abstract, so that only derived Class3 and Class4 can access it.
However, in Class3 I cannot create GetPath() as public static override
(compiler error), only protected override. However, protected override means I cannot access the function from outside as Class3.GetPath(), in fact I
cannot access it at all.

I'm probably not understanding a basic concept here... I sure would
appreciate some help.

Thanks in advance!

-- Hans De Schrijver

Nov 16 '05 #3

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

Similar topics

3
by: N Khan via .NET 247 | last post by:
Hi, I know the usage of access modifier ?public? in DLL assembliesbut I am a bit puzzled that if let say I have a public class inan exe assembly then what purpose access modifier ?public?...
54
by: richard_quick_uk | last post by:
Hi, If anyone's got the time I'd really appreciate any feedback on the accessibility of this site: http://www.cata.co.uk/_index.a­sp
0
by: Veli-Pekka Tätilä | last post by:
Hi, My first post here. I've found some serious accessibility flaws in the Python 2.4 docs and wish they could be rectified over time. I'm very new to Python and initially contacted docs at python...
7
by: ian_malcom_im | last post by:
Hi all i'm reading up on the internals of the CLR and I noticed that it is possible to make a class have the famandassem accessibility modifier. I've looked at the C# language reference and I...
8
by: Pete Davis | last post by:
First of all, I apologize for cross-posting to so many groups, but clearly there are only 2 people on the planet that understand MS Accessibility in ..NET and I'm hoping I might reach just one of...
4
by: waltborders | last post by:
Hi, Because the blind are unable to use a mouse, keyboard navigation is key. A major difficulty is that not all windows forms controls are keyboard 'tab-able' or 'arrow-able' or have "tab...
3
by: Brian Cryer | last post by:
I posted this question recently to microsoft.public.dotnet.languages.vb but didn't get any answer. I'm hoping that someone here will be able to help me. I'm working on a project using VB.NET...
1
by: krishnakant Mane | last post by:
has any one tried py gtk on windows? I tried to do a google search for accessibility related issues but did not find any thing specific to pygtk and windows accessibility. I even tried to search...
9
by: dylan.miller | last post by:
I'm having trouble understanding the internal access modifier. There are many classes in my assembly that should not be accessible outside of the assembly. I've used the internal access modifier...
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
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
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
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
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.