What is OOP (Object Oriented Programming)?
Working with Classes and Objects
Class Members
Access Modifiers - Encapsulation
It's all about learning, it's for fresher, intermediate, and for experienced to brush up the base.
Friday, April 2, 2021
C# Object Oriented Programming 101
What is Interface?
The interface is used to achieve abstraction in C#. It can only contain method declarations and properties. It is a contract between two entities.
I am using the same example from the previous post on Abstraction, to know more about what is abstraction you can visit the same post.
{
void Sound(); //Only method signature
- Like abstract classes, no instance creation so no constructor is allowed.is allowed for Interfaces as well
- Declaring interface with I comes out of practice to identify the same.
- Interfaces can contain methods and properties but not fields
- All members of interface are abstract and public, you do not need to use public access modifiers
- Derived classes must have an implementation of Interface members, you do not require to use override keyword to implement the method like abstract classes
- The interface provides security and standard contract
class Dove: IBird //Inherited Interface
{
public void Sound() //interface method implementation
{
Console.WriteLine("Coo Coo");
}
}
above is an implementation example of Interface IBird to Dove class.
Monday, March 29, 2021
What is OOP (Object Oriented Programming)?
Object-Oriented Programming is about creating Objects out of Classes
What is a Class?
Class is nothing but a blue print or a template for an object. It contains the attributes and methods.
For example, Car is a class and Audi, Mercedes, Porche, Farrari are objects of it.
What is an Object?
An instantiation of the class creates and an Object. This helps to reduce the repetition of code.
For example, from above one Audi is an object created from a abstract Car class.
Pillars of Object-Oriented Programming
- Encapsulation
- This means show only necessary to the outer world, achieved through Access Modifiers
- Inheritance
- Inheriting properties from a parent object makes it more reusable and extensible
- Helps to remove redundant code
- Polymorphism
- Same method signature with various forms or taste
- Dynamic Polymorphism
- Static Polymorphism
- Abstraction
- This helps to hide the complexity in your code
- Abstract classes and methods help to achieve multiple forms and are reusable in nature
Advantages of Object-Oriented Programming
- Reduce repetition of code
- Clear Code, Less Code
- Faster and manageable
- Easy to maintain, modify and debug
- Provides reusable application framework
- Rapid development
C# Interview Prep: 100 Common Questions for 0-3 Years Experience
Common C# Interview Questions Basics of C# Language: What is C#? C# (pronounced C sharp) is a modern, object-oriented programming language...
-
Design Patterns In software engineering, design patterns are time-tested solutions that mean general problems that are frequent to happen ...
-
I am trying to explain C# with Object-Oriented Programming in a much easy language with examples. To help out to clear basic thumb rules and...
-
I would request you to review my previous blog post for a basic understanding of Object Oriented Programming (To Read Click Me) From the pre...