BCA / B.Tech 10 min read

Object Orientation in .NET

Quick Summary & Key Takeaways

  • • Subject Focus: .Net Notes in English (BCA / B.Tech Syllabus)
  • • Core Topic: Object Orientation in .NET - General Topics
  • • Overview: Object Orientation in .NET in Hindi | Object Orientation in .NET in Hindi :In the .NET platform, Object-Oriented Programming (OOP) is an important ...
  • • Key Concepts: Object orientation, Classes inheritance polymorphism encapsulation Hindi, Abstraction SOLID principles,Object orientation, Classes inheritance polymorphism encapsulation, Abstraction SOLID principles

Object Orientation in .NET in Hindi | Object Orientation in .NET in Hindi :


  • In the .NET platform, Object-Oriented Programming (OOP) is an important programming pattern that uses data and its related functions as a single unit.
  • In this pattern, the program is divided into small objects that represent real-world entities.
  • .NET's programming languages, such as C# and VB.NET, are based on the main principles of OOP.

The four main principles of Object-Oriented Programming:

Abstraction: 

  • This is the principle of hiding unnecessary details and exposing only important information.
  • Example: If we create a "Car" class, we will expose only its essential features (like Start(), Stop()), not the complexity inside the engine.
Encapsulation: This is the principle of bundling data and its related functions together.

Example:


class Car
{
    private string engine; // This is private
    public void StartEngine()
    {
        Console.WriteLine("Engine Started");
    }
}
Here, the engine is private and cannot be accessed directly.

Inheritance: This gives a class the ability to inherit properties and methods from another class.

Example:

class Vehicle
{
    public void Move()
    {
        Console.WriteLine("Vehicle is moving");
    }
}
class Car : Vehicle
{
    public void StartEngine()
    {
        Console.WriteLine("Car engine started");
    }
}

Polymorphism: This means "many forms". It allows a method to work in different ways.

Example:

class Shape
{
    public virtual void Draw()
    {
        Console.WriteLine("Drawing Shape");
    }
}
class Circle : Shape
{
    public override void Draw()
    {
        Console.WriteLine("Drawing Circle");
    }
}

Important Features of OOP in .NET: Class: A class is a blueprint or template that defines objects.

Example:

class Person
{
    public string Name;
    public void Speak()
    {
        Console.WriteLine("Hello, I am " + Name);
    }
}

Object: An instance of a class, which is stored in memory.

Example:

Person person = new Person();
person.Name = "Amit";
person.Speak();

Constructor: This is a special method of a class that initializes an object.

Example:

class Car
{
    public string Brand;
    public Car(string brand)
    {
        Brand = brand;
    }
}

Properties: Through properties, we can access private fields in a secure way.

Example:

class Employee
{
    private string name;
    public string Name
    {
        get { return name; }
        set { name = value; }
    }
}

Interface: This is like a contract, which contains only the signatures of methods.

Example:

interface IVehicle
{
    void Drive();
}
class Bike : IVehicle
{
    public void Drive()
    {
        Console.WriteLine("Bike is driving");
    }
}

Delegates and Events: These refer to a method like a pointer at runtime.

Advantages of OOP in Hindi | Advantages of OOP:

  • Reusability: Code can be used again and again.
  • Modularity: It is easy to divide a large program into small modules.
  • Support for Real-World Entities: Brings programming closer to real-life problems.
  • Data Security: Data remains secure due to encapsulation.

Frequently Asked Questions (FAQs)

Object Orientation in .NET in Hindi | Object Orientation in .NET in Hindi :In the .NET platform, Object-Oriented Programming (OOP) is an important programming pattern that uses data and its related functions as a single unit.In this pattern, the program is divided into small objects that represent real-world entities..NET's programming languages, such as C# and VB.NET, are based on the main principles of OOP.The four main principles of Object-Oriented Programming:Abstraction: This is the principle of hiding unnecessary details and exposing only important information.Example: If we create a "Car" class, we will expose only its essential features (like Start(), Stop()), not the complexity inside the engine.Encapsulation: This is the principle of bundling data and its related functions together.Example:class Car{    private string engine; // This is private    public void StartEngine()    {        Console.WriteLine("Engine Started");    }}Here, the engine is private and cannot be accessed directly.Inheritance: This gives a class the ability to inherit properties and methods from another class.Example:class Vehicle{    public void Move()    {        Console.WriteLine("Vehicle is moving");    }}class Car : Vehicle{    public void StartEngine()    {        Console.WriteLine("Car engine started");    }}Polymorphism: This means "many forms".
Understanding Object Orientation in .NET is fundamental to mastering .Net Notes in English. It covers crucial concepts, solved problems, and revision points essential for academic and entrance exam success.
You can read free solved examples, detailed explanations, and key formulas for Object Orientation in .NET directly on the NotesMedia website or by downloading the NotesMedia App.