Generic derivance and embedded classes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • none

    Generic derivance and embedded classes

    Hello.
    Could anybody tell me why the following code:

    public abstract class Derived : Base<Derived.De rivedClass>
    {
    protected sealed class DerivedClass : Base<Derived.De rivedClass>.Bas eClass
    {
    }
    }

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

    gives me a <Derived.Derive dClass>.BaseCla ss' is inaccessible due to its
    protection level(CS0122) error?

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

    #2
    Re: Generic derivance and embedded classes

    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.De rivedClass>.Bas eClass
    This does not mean DerivedClass is deriving from Base<T>.

    --
    Dave Sexton

    "none" <""lcid-fire\"@(none)"w rote in message
    news:%230NpHAFA HHA.4740@TK2MSF TNGP03.phx.gbl. ..
    Hello.
    Could anybody tell me why the following code:
    >
    public abstract class Derived : Base<Derived.De rivedClass>
    {
    protected sealed class DerivedClass : Base<Derived.De rivedClass>.Bas eClass
    {
    }
    }
    >
    public abstract class Base<Twhere T : BaseClass
    {
    protected abstract class BaseClass
    {
    }
    }
    >
    gives me a <Derived.Derive dClass>.BaseCla ss' is inaccessible due to its
    protection level(CS0122) error?
    >
    I don't get why I have a problem with protection level...

    Comment

    • none

      #3
      Re: Generic derivance and embedded classes

      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.

      Comment

      • Dave Sexton

        #4
        Re: Generic derivance and embedded classes

        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)"w rote in message
        news:OjyPW1LAHH A.2328@TK2MSFTN GP02.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.

        Comment

        Working...