• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
info@dotnettec.com | +91-8800268750

DotNetTec

  • Home
  • Tutorials
    • Programming Language
      • C#
      • JavaScript
    • .Net Development
      • .NET Framework
      • ASP.NET Web Forms
      • MVC Architecture
      • Web API
      • .NET Core Framework
    • Front End Frameworks
      • JavaScript
      • HTML
    • Cloud Computing
      • Microsoft Azure
    • Database
      • SQL Server
    • Google Maps API
    • RPA
      • Blue Prism
      • UiPath
  • How to
  • Knowledge Base
  • Shop

What is the difference between abstract class and interface in C#

February 20, 2020 by Ravi Kumar Leave a Comment

In this article, I will answer from one of the most frequently asked C# Interview Questions: what is the difference between abstract class and interface in C#.

  • Keep reading on How to Convert JSON to Datatable in C#

Difference between Interface and Abstract Class

Abstract ClassInterface
  • An abstract class contains at least one abstract member and others, non-abstract members. Like a simple class, an abstract class can have data members and member functions
  • An interface has only the member’s declaration or signature and implicitly every member of an interface is public and abstract. It contains only properties, indexers, methods, delegates and events signature
  • An abstract class contains at least one abstract member and others, non-abstract members. Like a simple class, an abstract class can have data members and member functions
  • It cannot contains constants members, constructors, destructors, instance variables, static members or nested interfaces.
  • It can have field members.
  • It cannot have field members.
  • It can have public, protected and private members.
  • It can have only public members.
  • It can have public, protected and private members.
  • Methods have the only declaration.
  • It provides partial abstraction.
  • It provides the full abstraction
  • Only static constants are possible.
  • Static and Instance constants are possible.
  • It does not support multiple inheritances and so a class can inherit only one abstract class.
  • It supports multiple inheritances and so a class can inherit more than one interface.
  • Use an abstract class when you need to create multiple versions of your component and to provide default behaviors as well as common behaviors that multiple derived classes can share and override.
  • Use an interface when you need to provide a common functionality to unrelated classes and to create loosely coupled components, easily maintainable and pluggable components because the implementation of an interface is separated from itself.

Abstract class vs Interface

Reference: Stack Overflow

Conclusion

I hope you liked this article on what is the difference between an abstract class and an interface. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

Category iconC# Tag iconabstract class vs interface,  difference between abstract class and interface,  difference between interface and abstract class

Subscribe to our blog.

Get the latest posts delivered right to your inbox.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Google Maps Draw Polygon Get Coordinates
  • Check if point inside polygon Google Maps JavaScript
  • How to Create a Calendar Control in ASP.NET
  • Interview Etiquette Before, During and After
  • How to Attend Telephonic Interview Tips

Products

  • Online Shopping ASP.NET Project Source Code Online Shopping ASP.NET Project Source Code
    Rated 5.00 out of 5
    $69.00 $39.00
  • responsive-aspnet-mvc-grid-view ASP.NET MVC full Ajaxify and Bootstrap Grid with CRUD Operation
    Rated 4.67 out of 5
    $21.00 $9.00
  • eCommerce Website Source Code in ASP.NET eCommerce Website Source Code in ASP.NET $99.00
  • Hospital Management System Project ASP.Net Source Code
    Rated 5.00 out of 5
    $99.00
  • Whatsapp Bulk Message Sender Source Code WhatsApp Bulk Message Sender Source Code
    Rated 5.00 out of 5
    $69.00

Footer

.NET Developers Blog

Learn .NET, Programming Languages, Web App Development, APIs Development & Integration, Google Maps JavaScript APIs, and Cloud Services, through the latest articles, step-by-step tutorials, code examples, live projects, interview ebooks, and best practices.

Sitemap

  • About
  • Blog
  • Shop
  • Contact
  • Privacy Policy

Expertise

  • Web Development
  • Custom Software Development
  • Web API Development
  • Google Maps APIs

Newsletter

Get the latest news, posts, and announcements straight to your inbox.

Copyright © 2021 DotNetTec.