OOP in CSharp Part2

Page 1

69

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


70

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


71

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


72

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


73

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


ls oo dT an er W rit ee Fr ith

Note:

rw

1. You cannot declare virtual methods as static

Ed

ito

2. You cannot declare virtual methods as private

ll P

DF

3. Virtual methods are supposed to be overriden by the new implementation of the same method in the child class

PD

Fi

4. Base class method may be declared with ‘virtual’, but derived class may or may not override that base class method 5. If derived class wants to override the base class method, then use the override keyword while providing new implementation of the same method in the child class

74


75

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


76

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


77

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


78

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


79

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


80

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


81

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


82

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


83

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


84

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


85

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


86

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


87

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


88

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


89

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


90

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


91

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


92

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


93

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


94

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


95

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


ls oo dT an er W rit ee Fr

PD

Fi

ll P

DF

Ed

ito

rw

ith

Note: If you implement a member of an interface in a class implicitly, you can call that member implicitly or explicitly, i.e., using nay of the ways.

96


97

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


98

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


99

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


100

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


101

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


102

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


103

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


104

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


105

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


106

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


107

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


108

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


109

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


110

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


111

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


ls oo dT an er W rit ee Fr ith

Note:

PD

Fi

ll P

DF

Ed

ito

rw

* --ďƒ You can declare many overloaded constructors, but all of them have to assign value to fields. So, practically, only one overloaded constructor is enough to do the job.

112


113

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


114

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


115

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


116

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


117

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


118

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


119

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


120

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


121

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


122

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


123

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


124

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


125

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


126

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


127

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


128

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


129

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


130

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


131

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


132

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


133

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


134

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


135

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


136

DF

ll P

Fi

PD

ith

rw

ito

Ed ee

Fr er

W rit an

ls

oo

dT


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.