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

Generic derivance and embedded classes

Hello.
Could anybody tell me why the following code:

public abstract class Derived : Base<Derived.DerivedClass>
{
protected sealed class DerivedClass : Base<Derived.DerivedClass>.BaseClass
{
}
}

public abstract class Base<Twhere T : BaseClass
{
protected abstract class BaseClass
{
}
}

gives me a <Derived.DerivedClass>.BaseClass' is inaccessible due to its
protection level(CS0122) error?

I don't get why I have a problem with protection level...
Nov 4 '06 #1
3 1243
Hi,

BaseClass is a protected member of Base<T>, which means that it may only be
accessed by Base<Titself or derived Types.

DerivedClass does not derive from Base<Tand therefore cannot access
BaseClass.
Base<Derived.DerivedClass>.BaseClass
This does not mean DerivedClass is deriving from Base<T>.

--
Dave Sexton

"none" <""lcid-fire\"@(none)"wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hello.
Could anybody tell me why the following code:

public abstract class Derived : Base<Derived.DerivedClass>
{
protected sealed class DerivedClass : Base<Derived.DerivedClass>.BaseClass
{
}
}

public abstract class Base<Twhere T : BaseClass
{
protected abstract class BaseClass
{
}
}

gives me a <Derived.DerivedClass>.BaseClass' is inaccessible due to its
protection level(CS0122) error?

I don't get why I have a problem with protection level...

Nov 5 '06 #2
Dave Sexton wrote:
Hi,

BaseClass is a protected member of Base<T>, which means that it may only be
accessed by Base<Titself or derived Types.

DerivedClass does not derive from Base<Tand therefore cannot access
BaseClass.
I thought, that since DerivedClass in embedded in Derived it can
automaticly access all embedded classes of Base since Derived is derived
from Base.

So I tried making the DerivedClass and BaseClass public and now I get
some other errors which I have to figure out ;)

Thanks for your clarification.
Nov 5 '06 #3
Hi,

Do you want to explain what you're trying to accomplish?

Maybe someone will be able to give you some pointers and supply working code.

--
Dave Sexton

"none" <""lcid-fire\"@(none)"wrote in message
news:Oj**************@TK2MSFTNGP02.phx.gbl...
Dave Sexton wrote:
>Hi,

BaseClass is a protected member of Base<T>, which means that it may only be
accessed by Base<Titself or derived Types.

DerivedClass does not derive from Base<Tand therefore cannot access
BaseClass.
I thought, that since DerivedClass in embedded in Derived it can
automaticly access all embedded classes of Base since Derived is derived
from Base.

So I tried making the DerivedClass and BaseClass public and now I get
some other errors which I have to figure out ;)

Thanks for your clarification.

Nov 5 '06 #4

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

Similar topics

3
by: Jim Newton | last post by:
hi all, i'm relatively new to python. I find it a pretty interesting language but also somewhat limiting compared to lisp. I notice that the language does provide a few lispy type nicities, but...
17
by: Andreas Huber | last post by:
What follows is a discussion of my experience with .NET generics & the ..NET framework (as implemented in the Visual Studio 2005 Beta 1), which leads to questions as to why certain things are the...
6
by: Robin | last post by:
Are there any generic classes available that can be used in VB.Net to perform common tasks such as Database Access and Logging?
6
by: Urs Eichmann | last post by:
While experimenting with the Feb CTP Edition of VB 2005, I came across "generic procedures". You can write: Public Class Foo Public Sub MySub(Of tDisp As IDisposable)(ByVal vMyParm As Integer)...
25
by: Lars | last post by:
Hi, I have a base class holding a generic list that needs to be accessed by both the base class and its subclasses. What is the best solution to this? I am fairly new to generics, but I am...
3
by: Tigger | last post by:
I have an object which could be compared to a DataTable/List which I am trying to genericify. I've spent about a day so far in refactoring and in the process gone through some hoops and hit some...
5
by: Torben Laursen | last post by:
I am writing a COM in C# using visual studio 2005 and VSTO. Inside the code I use some support classes that are generic but they are not used in the inferface of the COM. However I still get a...
3
by: Samuel R. Neff | last post by:
Is there any way to declare a static variable within a generic type definition and have that variable be shared across all constructed generic types? For example, how can I modify this code: ...
10
by: phancey | last post by:
I'm quite new to generics. I have 2 generic classes: MyClass<Tand MyOtherClass<T>. MyClass<Thas 2 public Add methods Add(MyOtherClass<T>); Add(MyOtherClass<Wrapper<T>>); (Wrapper<Tis another...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.