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. abstract method in non abstract class

abstract method in non abstract class

Scheduled Pinned Locked Moved C#
question
4 Posts 4 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
    mukkanti007
    wrote on last edited by
    #1

    Hi, I have a question regarding abstract methods if i place an abstract method in non abstract class what will happen if i doesnt implement that method in derived class Any updates would be appreciated Thanks

    Thanks Mukkanti

    C P G 3 Replies Last reply
    0
    • M mukkanti007

      Hi, I have a question regarding abstract methods if i place an abstract method in non abstract class what will happen if i doesnt implement that method in derived class Any updates would be appreciated Thanks

      Thanks Mukkanti

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      mukkanti007 wrote:

      if i place an abstract method in non abstract class

      You can't. It breaks the semantics of being abstract.

      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

      1 Reply Last reply
      0
      • M mukkanti007

        Hi, I have a question regarding abstract methods if i place an abstract method in non abstract class what will happen if i doesnt implement that method in derived class Any updates would be appreciated Thanks

        Thanks Mukkanti

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

        If the class contains an abstract member, then the class must be marked abstract.

        1 Reply Last reply
        0
        • M mukkanti007

          Hi, I have a question regarding abstract methods if i place an abstract method in non abstract class what will happen if i doesnt implement that method in derived class Any updates would be appreciated Thanks

          Thanks Mukkanti

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          mukkanti007 wrote:

          if i place an abstract method in non abstract class

          Not possible. If you want a method that is optional to override, you should make it virtual. The base class has to have an implementation of the method, but you can just throw an NotImplementedException exception in the method.

          Despite everything, the person most likely to be fooling you next is yourself.

          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