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. When we have to use abstract and when we have to use interface ?

When we have to use abstract and when we have to use interface ?

Scheduled Pinned Locked Moved C#
question
3 Posts 3 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.
  • M Offline
    M Offline
    md_azy
    wrote on last edited by
    #1

    Hi , When we have to use abstract and when we have to use interface in real time coding Thanks in advance Azeez.

    P P 2 Replies Last reply
    0
    • M md_azy

      Hi , When we have to use abstract and when we have to use interface in real time coding Thanks in advance Azeez.

      P Offline
      P Offline
      puri keemti
      wrote on last edited by
      #2

      Interface is lightweight than Abstract.... **Abstract** When you don't clear about the future expansion of the framework... For creating multiple version application.. For creating products... For putting common behavior so that drived classes can use it without writing code again & again... **Interface** For defining rules and business policies... To enforce something.... to overcome the problem of multiple inhetitence

      1 Reply Last reply
      0
      • M md_azy

        Hi , When we have to use abstract and when we have to use interface in real time coding Thanks in advance Azeez.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        You never have to use either. When defining a group of similar classes you may find it beneficial to define an interface (or more than one) that specifies what things the classes have in common. If there is some common code that the classes should share, you may want to put that code in a base class. If that base class itself should not be instantiated, then you may want to mark it as abstract. In the long run, you probably should always define an interface whenever you define a base class.

        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