Introduction
As we know, C# is an Object Oriented Programming language that provides the ability to reuse existing code. To reuse existing code, C# provides various object-oriented concepts such as classes, objects, properties, methods, structs, and records.
Now in this article, we learn about the overview of classes that are part of C# Object Oriented Programming concepts, and in the next article, we learn in detail about each class in depth. Let us start with defining the class.
What is a class in C#?
Classes are user-defined data types that represent the state and behavior of an object. The state represents the properties, and behavior is the action that objects can perform.
Classes can be declared using the following access specifiers that limit the accessibility of classes to other classes. However, some classes do not require any access modifiers.
- Public
- Private
- Protected
- Internal
- Protected internal
To learn the details of access specifiers, check out Access Modifiers in C#.
For example
public class Accounts
{
}
Some Key points about classes:
- Classes are reference types that hold the object created dynamically in a heap.
- All classes have a base type of System.Object.
- The default access modifier of a class is Internal.
- The default access modifier of methods and variables is Private.
- Directly inside the namespaces, declarations of private classes are not allowed.
Types of classes in C#
What is an Abstract Class in C#?
An abstract class is a class that provides a common definition to the subclasses, and this is the type of class whose object is not created.
Some key points of Abstract classes are:
- Abstract classes are declared using the abstract keyword.
- We cannot create an object of an abstract class.
- It must be inherited in a subclass if you want to use it.
- An Abstract class contains both abstract and non-abstract methods.
- The methods inside the abstract class can either have an or no implementation.
- We can inherit two abstract classes; in this case, implementation of the base class method is optional.
- An Abstract class has only one subclass.
- Methods inside the abstract class cannot be private.
- If there is at least one method abstract in a class, then the class must be abstract.

Join the conversation! Your thoughts help the community grow.