Overloading: Method Overloading Operator Overloading
Overloading: Method Overloading Operator Overloading
METHOD OVERLOADING
OPERATOR OVERLOADING
Operator Overloading
Operator overloading is also an approach defining multiple behaviours to an operator and
those behaviours will vary based on the operand types between which the operator is used .
For example + is an addition operator when used between 2 numeric operands and it is an
concatenation operator when used between 2 string operands
Number + NumberAddition
String + String Concatenation
A. Public static string operator +(string a, string b);
B. Public static int operator +(int a,int b)
C. Public static bool operator ==(string a, string b)
D. Public static bool operator !=(string a, string b)
String s1=“hi”;
String s2=“hello”;
String s3=s1+s2;
Bool b1=s1==s2; Bool b2=s1!=s2;