Professional Documents
Culture Documents
OOP WITH C#
LOGO CLASS
• Class:
o Access Modifiers;
o Field;
o Constructor:
o Method:
o Getter/Setter;
o Property:
Auto-implemented Property.
LOGO CLASS
• Class:
LOGO ACCESS MODIFIER
• Access modifiers are applied on the declaration of the class,
method, properties, fields and other members.
• Define the accessibility of the class and its members.
LOGO PROPERTY & ENCAPSULATION
LOGO PROPERTY & ENCAPSULATION
• A property can be defined using getters and setters:
LOGO INHERITANCE
• Ability allows a class having members of an existed class
→ Re-used code.
class PERSON class STUDENT
ID_Num ID_Num
Name Name
YearOfBirth inherited YearOfBirth
Address Address
getID_Num() getID_Num()
setID_Num(newID) setID_Num(newID)
...... ......
“is a”
relationship
RollNum
class STUDENT Score
extensions
getScore()
RollNum setSore(newScore)
Score ......
getScore()
setSore(newScore)
...... Son = Father + extensions
LOGO INHERITANCE
• C# and .NET support single inheritance only.
LOGO POLYMORPHISM
• Overload & Override (keyword new ???)
LOGO CLASS OBJECT
LOGO CLASS OBJECT: OVERRIDE
LOGO CLASS OBJECT: OVERRIDE
LOGO CASTING
• Value type: conversion and casting