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 and abstract"

"interface and abstract"

Scheduled Pinned Locked Moved C#
8 Posts 6 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.
  • R Offline
    R Offline
    ravikiranreddydharmannagari
    wrote on last edited by
    #1

    in what scenario we will go for abstract and interface plz let me know with regards ravi

    S P M L 4 Replies Last reply
    0
    • R ravikiranreddydharmannagari

      in what scenario we will go for abstract and interface plz let me know with regards ravi

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Recommendations for Abstract Classes vs. Interfaces[^]


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      1 Reply Last reply
      0
      • R ravikiranreddydharmannagari

        in what scenario we will go for abstract and interface plz let me know with regards ravi

        P Offline
        P Offline
        Parwej Ahamad
        wrote on last edited by
        #3

        Interface : (1) For supporting the mutiple inheritence (2) For initialize runtime objects (3) For implementing group of methos Abstract Class : When you maintain the Base lass standard, You can use Abstract class. -- modified at 6:53 Friday 16th February, 2007

        Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

        D 1 Reply Last reply
        0
        • R ravikiranreddydharmannagari

          in what scenario we will go for abstract and interface plz let me know with regards ravi

          M Offline
          M Offline
          Michael Sync
          wrote on last edited by
          #4

          Abstract here is nice article.. Abstract class versus Interface

          Thanks and Regards, Michael Sync Blog: http://michaelsync.net

          1 Reply Last reply
          0
          • P Parwej Ahamad

            Interface : (1) For supporting the mutiple inheritence (2) For initialize runtime objects (3) For implementing group of methos Abstract Class : When you maintain the Base lass standard, You can use Abstract class. -- modified at 6:53 Friday 16th February, 2007

            Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

            D Offline
            D Offline
            Daniel Turini
            wrote on last edited by
            #5

            Parwej Ahamad wrote:

            1. For supporting the mutiple inheritence

            No, .NET does not support MI. We use interfaces to support polymorphism.

            P 1 Reply Last reply
            0
            • D Daniel Turini

              Parwej Ahamad wrote:

              1. For supporting the mutiple inheritence

              No, .NET does not support MI. We use interfaces to support polymorphism.

              P Offline
              P Offline
              Parwej Ahamad
              wrote on last edited by
              #6

              Dear i know .Net does not support multiple inheritence but u can implement mutiple inheritence with the help of Interface :-D

              Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

              D 1 Reply Last reply
              0
              • P Parwej Ahamad

                Dear i know .Net does not support multiple inheritence but u can implement mutiple inheritence with the help of Interface :-D

                Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

                D Offline
                D Offline
                Daniel Turini
                wrote on last edited by
                #7

                Parwej Ahamad wrote:

                but u can implement mutiple inheritence with the help of Interface

                No, you can't. You're thinking that "multiple inheritance" is the same as "multiple interfaces". It is not. Multiple interfaces are a synonym of something called "polymorphism", but polymorphism is a mere requirement for multiple inheritance, which does a lot more than polymorphism.

                1 Reply Last reply
                0
                • R ravikiranreddydharmannagari

                  in what scenario we will go for abstract and interface plz let me know with regards ravi

                  L Offline
                  L Offline
                  LogiPro101
                  wrote on last edited by
                  #8

                  Difference between Abstract classes and Interface Little background: A real world entity is represented in an OOP world as object. Objects are defined as classes any language. A class defines objects in two aspects Object's characteristics - Data Members Object's functionality - Member functions So, when the classes that are forced to provide implementations of the functions prototypes that are defined in either ‘interfaces’ or a ‘abstract class’ are not belonging to the same family (having some inherited parental characteristics from same parent directly or indirectly) but are rather related through some functionalities then 100% we will go with interface and if above said classes are belonging to same family then we should go with abstract class inheritance. Also in case of inheritance as everything is a specialization of base parent object so there is allowance of providing some default definitions of the functions that are needed to be implemented further by specialized classes. This is not any way allowed in interfaces because implementing classes are not belonging to same family and are not any way related by characteristics. An Example: We have four real world objects: • Airplane • Bird • Sparrow • Eagle We have one method that is a functionality of all above objects • Fly Now all objects share common functionality flying in air but differ in the mechanism they use to fly. Also by close look we see that in general there is some common characteristics (as well as some common functionalities) between Sparrow and Eagle that can be a part of common class Bird (that has to be abstract because there is no real thing like bird!). But any way Airplane can't be related to Bird or its specialized classes Sparrow and Eagle. So if want to expose fly functionality to outer world and want their implementations in Airplane and Sparrow (or any bird), so I will 100% go for Interface and Abstract classes will be a big NO! But if we exclude Airplane want that fly functionality is exposed to outer world and its implementing classes are Bird, Sparrow and Eagle then 'Abstract Classes' is the best of best choice. Happy programming! Please feel free in writing to me for further clarifications on other OOP concepts (im.himanshu2006@gmail.com) Himanshu

                  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