Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Interface reimplementation

Interface reimplementation

Scheduled Pinned Locked Moved C#
oopquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Svekke
    wrote on last edited by
    #1

    Suppose ... public interface IMyInterface{ void MyMethod(); } public class ClassA:IMyInterface{ public void MyMethod(){} } public class ClassB:ClassA,IMyInterface{ public void MyMethod(){} } Can anyone tell me if it's required to specify that ClassB inherits IMyInterface ? The interface is to my opinion inherited through the base class ClassA, but it seems specifying (or not) the interface inheritance in the derived class ClassB makes no difference.

    L 1 Reply Last reply
    0
    • S Svekke

      Suppose ... public interface IMyInterface{ void MyMethod(); } public class ClassA:IMyInterface{ public void MyMethod(){} } public class ClassB:ClassA,IMyInterface{ public void MyMethod(){} } Can anyone tell me if it's required to specify that ClassB inherits IMyInterface ? The interface is to my opinion inherited through the base class ClassA, but it seems specifying (or not) the interface inheritance in the derived class ClassB makes no difference.

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      You dont need to unless u want to 'override' the behaviour. This normally means you have designed something wrong :) To override the interface implementation, you would likely have to use an explicit implementation.

      **

      xacc.ide-0.2.0.77 - now with C# 3.5 support and Navigation Bar!^
      New xacc.ide release RSS feed^

      **

      S 1 Reply Last reply
      0
      • L leppie

        You dont need to unless u want to 'override' the behaviour. This normally means you have designed something wrong :) To override the interface implementation, you would likely have to use an explicit implementation.

        **

        xacc.ide-0.2.0.77 - now with C# 3.5 support and Navigation Bar!^
        New xacc.ide release RSS feed^

        **

        S Offline
        S Offline
        Svekke
        wrote on last edited by
        #3

        Indeed I want to override (reimplement) the interface behaviour in the derived ClassB, but my question really is wether to use ... public class ClassB:ClassA,IMyInterface or public class ClassB:ClassA as the ClassB declaration ? Both work for me, but I was wondering if there's a difference (behind the scenes ?) for either one of them !

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups