.net framework interface implementation

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

    #1

    .net framework interface implementation

    Hi,

    I created a class that implements the
    System.Collecti ons.IDictionary interface and I declared
    methods for implementing IDictionary, and also the
    interfaces it inherited from, include ICollection and
    IEnumerable.

    I have problem in compiling my class and the C# compiler
    complained about the method GetEnumerator() , which has
    been implemented twice. I looked at the interfaces again
    and found that both IEnumerable and IDictionary have this
    method declared and I had both implemented. The one
    declared in IEnumerable is :

    public IEnumerator GetEnumerator() ;

    and the one declared in IDictionary is:

    public IDictionaryEnum erator GetEnumerator() ;

    I tried to remove the IEnumerable.Get Enumerator
    implementation but then the C# complains on the
    incomplete implementation of the interface. Of course
    same thing happened when I tried to remove the
    IDictionary.Get Enumerator implementation. Therefore I
    could remove neither of them.

    I believe this could be a simple issue but I just don't
    know how to resolve this problem. Any help out there is
    appreciated.

    Thanks in advance


  • Horatiu Ripa

    #2
    Re: .net framework interface implementation

    IDictionaryEnum erator IDictionary.Get Enumerator()
    {
    ......
    }
    IEnumerator IEnumerable.Get Enumerator()
    {
    ........
    }

    anyway, you have to cast to the specific interface on use.



    --
    Horatiu Ripa
    Software Development Manager
    Business Logic Systems LTD
    21 Victor Babes str., 1st floor, 3400 Cluj-Napoca, Romania
    Phone/Fax: +40 264 590703
    Web: www.businesslogic.co.uk

    This email (email message and any attachments) is strictly confidential, possibly privileged and is intended solely for the person or organization to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or take any action in reliance on it. If you have received this email in error, please inform the sender immediately before deleting it. Business Logic Systems Ltd accepts no responsibility for any advice, opinion, conclusion or other information contained in this email or arising from its disclosure.

    "chan" <garlic77@hotma il.com> wrote in message news:014e01c37c 10$60825120$a00 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > I created a class that implements the
    > System.Collecti ons.IDictionary interface and I declared
    > methods for implementing IDictionary, and also the
    > interfaces it inherited from, include ICollection and
    > IEnumerable.
    >
    > I have problem in compiling my class and the C# compiler
    > complained about the method GetEnumerator() , which has
    > been implemented twice. I looked at the interfaces again
    > and found that both IEnumerable and IDictionary have this
    > method declared and I had both implemented. The one
    > declared in IEnumerable is :
    >
    > public IEnumerator GetEnumerator() ;
    >
    > and the one declared in IDictionary is:
    >
    > public IDictionaryEnum erator GetEnumerator() ;
    >
    > I tried to remove the IEnumerable.Get Enumerator
    > implementation but then the C# complains on the
    > incomplete implementation of the interface. Of course
    > same thing happened when I tried to remove the
    > IDictionary.Get Enumerator implementation. Therefore I
    > could remove neither of them.
    >
    > I believe this could be a simple issue but I just don't
    > know how to resolve this problem. Any help out there is
    > appreciated.
    >
    > Thanks in advance
    >
    >[/color]

    Comment

    • chan

      #3
      Re: .net framework interface implementation

      Thank you Horatiu.
      [color=blue]
      >-----Original Message-----
      >IDictionaryEnu merator IDictionary.Get Enumerator()
      >{
      >......
      >}
      >IEnumerator IEnumerable.Get Enumerator()
      >{
      >........
      >}
      >
      >anyway, you have to cast to the specific interface on[/color]
      use.[color=blue]
      >
      >
      >
      >--
      >Horatiu Ripa
      >Software Development Manager
      >Business Logic Systems LTD
      >21 Victor Babes str., 1st floor, 3400 Cluj-Napoca,[/color]
      Romania[color=blue]
      >Phone/Fax: +40 264 590703
      >Web: www.businesslogic.co.uk
      >
      >This email (email message and any attachments) is[/color]
      strictly confidential, possibly privileged and is
      intended solely for the person or organization to whom it
      is addressed. If you are not the intended recipient, you
      must not copy, distribute or take any action in reliance
      on it. If you have received this email in error, please
      inform the sender immediately before deleting it.
      Business Logic Systems Ltd accepts no responsibility for
      any advice, opinion, conclusion or other information
      contained in this email or arising from its disclosure.[color=blue]
      >
      >"chan" <garlic77@hotma il.com> wrote in message[/color]
      news:014e01c37c 10$60825120$a00 1280a@phx.gbl.. .[color=blue][color=green]
      >> Hi,
      >>
      >> I created a class that implements the
      >> System.Collecti ons.IDictionary interface and I[/color][/color]
      declared[color=blue][color=green]
      >> methods for implementing IDictionary, and also the
      >> interfaces it inherited from, include ICollection and
      >> IEnumerable.
      >>
      >> I have problem in compiling my class and the C#[/color][/color]
      compiler[color=blue][color=green]
      >> complained about the method GetEnumerator() , which has
      >> been implemented twice. I looked at the interfaces[/color][/color]
      again[color=blue][color=green]
      >> and found that both IEnumerable and IDictionary have[/color][/color]
      this[color=blue][color=green]
      >> method declared and I had both implemented. The one
      >> declared in IEnumerable is :
      >>
      >> public IEnumerator GetEnumerator() ;
      >>
      >> and the one declared in IDictionary is:
      >>
      >> public IDictionaryEnum erator GetEnumerator() ;
      >>
      >> I tried to remove the IEnumerable.Get Enumerator
      >> implementation but then the C# complains on the
      >> incomplete implementation of the interface. Of course
      >> same thing happened when I tried to remove the
      >> IDictionary.Get Enumerator implementation. Therefore I
      >> could remove neither of them.
      >>
      >> I believe this could be a simple issue but I just[/color][/color]
      don't[color=blue][color=green]
      >> know how to resolve this problem. Any help out there[/color][/color]
      is[color=blue][color=green]
      >> appreciated.
      >>
      >> Thanks in advance
      >>
      >>[/color][/color]

      Comment

      Working...