Author - StudySection Post Views - 176 views
oops

OOPs Concept in C#

What is OOPs?

Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic.

What are the main concepts of OOPs:

  • Class:– A class is the core of Object-Oriented Programming language. It consists of data and functions. It is mandatory to create class in OOPs.

    Class Employee
    {
    Public void addemployee()[Function for adding employee details] {
    String name = “abc”;
    Int empid = 101;
    }
    }
  • Object:– Object is the run time entity of the class. We can access the class data of functions by creating an object of that class.

    Employee objEmp = new Employee();
  • Abstraction:– Abstraction is the concept of hiding. It means we show the user What we do not How we do it. We can achieve abstraction by placing the abstract keyword in front of the class name.

    abstract class MobilePhone {
    public void Calling();
    public void SendSMS();
    }

    Few of the properties of the abstract class are:

    1. Objects of the Abstract class can not be created.
    2. It can have both abstract and non-abstract methods
    3. It can have both constructors and static methods
    4. We must override all the abstract methods of the abstract class in the child class.
  • Encapsulation:
    Wrapping up the data and functioning together is known as Encapsulation.
    We can achieve encapsulation by declaring all the variables in the class as private and using properties to get and set those variables.
  • Polymorphism:
    Polymorphism means one name and many forms. It provides an ability to have multiple implementations with the same name in a class.
    There are 2 types of Polymorphism –

    1. Static / Compile Time Polymorphism
    2. Dynamic / Runtime Polymorphism

    polymorphism

  • Method Overloading:- In this concept, we create multiple functions with the same name and unique signatures and whenever we will call that function the compiler will decide which function to call based on the signature of the function.

    Syntax -
    public int Add(int a, int b, int c)
    {
    return a + b + c;
    }
    public int Add(int a, int b)
    {
    return a + b;
    }
  • Operator Overloading:
    It gives the ability to use the same operator for various operations.

    Syntax -
    access specifier className operator Operator_symbol (parameters)
    {
    // Code
    }
  • Method Overriding:
    In method overriding we define the function with the same name and signature in the child class.
  • Inheritance:
    It is a concept of reusing the already written code. We can inherit the code of the superclass and use it again in the child class.

    Important terminology:

    • Super Class – A class whose features are inherited is called a superclass.
    • Child Class – A class that is inheriting the superclass is known as child class.


    Syntax:
    class derived-class : base-class
    {
    // methods and fields
    }

    Types of Inheritance:

    1. Single Inheritance – In this, a subclass inherits the features of a single superclass.
    2. Multilevel Inheritance – In Multilevel Inheritance, a derived class inherits the base class as well as the derived class. It also acts as the base class for other classes.
    3. Hierarchical Inheritance – In this type of Inheritance, one class serves as a superclass (base class) for more than one subclass.

    Note: C# does not support multiple inheritances. We can achieve multiple inheritances with the help of the interface.

  • Interface: Interface is used to achieve the multiple inheritances which can not be achieved using the classes. The interface provides full abstraction because all of its methods are abstract and they can not have a body. All of the methods are public by default.

    Few points about Interface –

    • Its methods can not be private or protected, they are public by default.
    • An interface can inherit one or more interfaces.
    • A class that implements an interface must use a public access modifier.

Being the most extensively used JavaScript library, a jQuery certification will add enormous value to your skill-set. jQuery provides various functionalities to the developer in order to develop complex applications with ease and efficiency.

Leave a Reply

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

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri