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:
- Number juggling administrators (+ – */%)
- Bitwise administrators (and | << >>)
- Unary administrators (+ – ! ~ ++ – )
- Social administrators (== != < > <= >=)
- Compound task (+= – = *=/= %=)
We can’t over-burden following administrators are given beneath:
- Sensible administrators (&& ||)
- Transformation administrator ( () )
- Task administrator ( = )
- Dab or participation administrator ( . )
- Restrictive or ternary administrator ( ?: )
- Referential administrator ( – > )
- New administrator ( new )
- 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