Abstract Class in C#
In this post I will explain about what is abstract class in c#.
In my previous posts I have explained various topics like Difference between HttpGet and HttpPost Method, Jquery, asp.net, visual studio,C#.Net,Console application
Now in this post, I will explain Abstract Class in C# with appropriate example.
Abstract class is a special type of class which cannot be instantiated and it is used as a base class for another classes.In a Commonly, you will like to mark class that only represent base classes, and don’t want anyone to create objects of these class types. At that time make use of abstract classes to implement such functionality in C# using the modifier
An abstract class may contain either abstract methods or non-abstract methods. Abstract members do not have any implementation in the abstract class, but it has to be provided in its derived class.
Now, Open Visual Studio and create Console Application,Write below code in it.
abstract class AbstractHuman
{
public abstract void canWalk(); // Abstract method
public void canRun()
{
Console.WriteLine("This is NonAbstract Method");
}
}
The purpose of creating an abstract class is to provide basic functionality and/or common functionality that multiple derived classes can share and override.
Summary
You can also read about ASP.NET, C#.Net, JQUERY, AJAX, JavaScript
I hope you get an idea about Abstract Class in C#.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you liked this post, don’t forget to share this.