Professional Documents
Culture Documents
DAY3 DotNet 2017
DAY3 DotNet 2017
u Use
v Fraction a = new Fraction(1,2);
v Fraction b = new Fraction(3,4);
v Fraction c = a + b; //c.x == 10, c.y ==8
u The following operators can be overloaded
v Arithmetic: +, -, *,/ %,++, --
v Realational: ==, !=, <, >, <=, >=
v Bit operators: &, |, ^
v Other: !,~,>>,<<, true, false
u Must return value
Conversion Operators
u Implicit conversion
v long = int;
u Explicit conversion
v int = (int )long
u Conversion operators for custom types
u Use
v Fraction f = 3; //f.x ==2, f.y ==1
v Fraction l = (int)f; // I = 3
Nested Types
u
u Inner class can access all members of the outer class (even
private members)
u Outer class can access only public members of the inner class.
u Other class can access an inner class only if it is public.
u Nested class can also be structs, enums, delegates.
Thank you