What is Operator Overloading in C#?

In this article, we will find out about administrator over-burdening in C#, here, we will likewise learn – which administrators can be over-burden and which can’t be over-burden?

C# – Operator Overloading

It is a kind of polymorphism. As we realize that each administrator has a pre-characterized usage. However, utilizing administrator over-burdening we can relegate some exceptional undertaking to c# administrators as for client characterized information type like classes and structures.

We can over-burden some C# administrators; all C# administrators can’t be over-burden. We can over-burden following administrators that are given beneath:

  1. Number juggling administrators (+ – */%)
  2. Bitwise administrators (and | << >>)
  3. Unary administrators (+ – ! ~ ++ – )
  4. Social administrators (== != < > <= >=)
  5. Compound task (+= – = *=/= %=)

We can’t over-burden following administrators are given beneath:

  1. Sensible administrators (&& ||)
  2. Transformation administrator ( () )
  3. Task administrator ( = )
  4. Dab or participation administrator ( . )
  5. Restrictive or ternary administrator ( ?: )
  6. Referential administrator ( – > )
  7. New administrator ( new )
  8. Size of administrator ( sizeof() )

In C#, to over-burden any permitted administrator we have to utilize administrator keyword. Here we make a technique with given administrator like + , and administrator catchphrase. This strategy must be open and static. This technique can take just value contentions, here we can’t utilize ref or out parameters.

Syntax:

    public static return_type operator op (Type t)
    {
	    // Statements
    }

Here, Type must be a class or struct

Leave a Comment

error: Alert: Content is protected!!