Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4249436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:23:49+00:00 2026-05-21T04:23:49+00:00

I would like to know the difference between two conventions: Creating an abstract base

  • 0

I would like to know the difference between two conventions:

  1. Creating an abstract base class with an abstract method
    which will be implemented later on the derived classes.
  2. Creating an abstract base class without abstract methods
    but adding the relevant method later on the level of the derived classes.

What is the difference?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:23:50+00:00Added an answer on May 21, 2026 at 4:23 am

    Much like interfaces, abstract classes are designed to express a set of known operations for your types. Unlike interfaces however, abstract classes allow you to implement common/shared functionality that may be used by any derived type. E.g.:

    public abstract class LoggerBase
    {
      public abstract void Write(object item);
    
      protected virtual object FormatObject(object item)
      {
        return item;
      }
    }
    

    In this really basic example above, I’ve essentially done two things:

    1. Defined a contract that my derived types will conform to.
    2. Provides some default functionality that could be overriden if required.

    Given that I know that any derived type of LoggerBase will have a Write method, I can call that. The equivalent of the above as an interface could be:

    public interface ILogger
    {
      void Write(object item);
    }
    

    As an abstract class, I can provide an additional service FormatObject which can optionally be overriden, say if I was writing a ConsoleLogger, e.g.:

    public class ConsoleLogger : LoggerBase
    {
      public override void Write(object item)
      {
        Console.WriteLine(FormatObject(item));
      }
    }
    

    By marking the FormatObject method as virtual, it means I can provide a shared implementation. I can also override it:

    public class ConsoleLogger : LoggerBase
    {
      public override void Write(object item)
      {
        Console.WriteLine(FormatObject(item));
      }
    
      protected override object FormatObject(object item)
      {
        return item.ToString().ToUpper();
      }
    }
    

    So, the key parts are:

    1. abstract classes must be inherited.
    2. abstract methods must be implemented in derived types.
    3. virtual methods can be overriden in derived types.

    In the second scenario, because you wouldn’t be adding the functionality to the abstract base class, you couldn’t call that method when dealing with an instance of the base class directly. E.g., if I implemented ConsoleLogger.WriteSomethingElse, I couldn’t call it from LoggerBase.WriteSomethingElse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know is there any difference in performance between these two
I would like to know what is the exact difference between a class snippet
I would like to know how to calculate difference between two different timezones /
I would like to know the difference between below two values in mysql. show
i would like to know the difference between this two methods for initializing the
I am a newbie....I would really like to know detailed difference between two, and
I would like to know the difference between two strings and I'm using diff-lcs
I would like to know the difference in terms of performance between these two
I would like to know difference between these two lines: p.intro a{color=# ff99ff;} p
I would like to know what is the difference between those two categories that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.