beginning-C-Sharp-object-oriented-programming.pdf

(1272 KB) Pobierz
Beginning C# Object Oriented Programming
This free book is provided by courtesy of C# Corner and Mindcracker Network and
its authors. Feel free to share this book with your friends and co-workers.
Please do
not reproduce, republish, edit or copy this book.
Syed Shanu
(C# Corner MVP)
Index
Class
Object
Variable
Method
Access Modifiers
Encapsulation
Abstraction
Inheritance
Polymorphism
Abstract Class/Method
Virtual Method
Sealed Class/Method
Static Class/Method
Interface
Page No
1-4
4
4-5
6-10
10-12
13
13-14
14-17
18-19
19-21
21-23
23-25
25-29
30-32
About Author
Syed Shanu is basically from Madurai, Tamil Nadu, India.He was been working in South
Korea for past 8 years. He has 9+ years of Experience in Microsoft Technologies. His
work experience with Language and Technology start’s from ASP and SQL Server,
Then VB.NET and C# for PDA Application, Touch Screen Application Development,
Desktop Application, ASP.NET Web Application Development, MVC and WPF.
Syed Shanu
(C# Corner MVP)
Introduction
There are many explanations to be found in the internet about C# OOP, but here in my article
I will provide a very simple example. In this article, I will use a “House" (like the houses we
live in) as a realistic example for a better understanding of OOP in C#.
1. Class
A
Class
is a like a blueprint.
What is a blueprint?
A blueprint is an outline drawing of our actual plan. For example, if we plan to build our new
home, the engineer will explain our new house plan with a blueprint as shown in the image
below. Once we have finalized the plan the engineer will start building the house with the
same plan.
The same as for a blueprint class is an outline of a program. Using the class we can write our
own method and declare the variables and using the objects we can access the class method
and variables. The class will be complete with variables, methods and objects.
©2016 C# CORNER.
SHARE THIS DOCUMENT AS IT IS.
PLEASE DO NOT REPRODUCE, REPUBLISH, CHANGE OR COPY.
1
For a better understanding of OOP using a realistic example here I have explained a class for a
House. We can imagine a House as an example for a class. In a house, we will have rooms
like a living room, bedroom, kitchen and items like TV, refrigerator and so on. The house
owner can access and use all the rooms and room's items. The same as for a class with a group
of methods and variables. Rooms and each room's items are examples
of
methods
and
variables.
So we now have a complete house with all its rooms and room's
items. The house owner can access and use all the rooms and room's items. To access and use
a class, methods and variables here we use
Objects.
Objects are an instance of a class. We
will see the details about objects in the next section.
©2016 C# CORNER.
SHARE THIS DOCUMENT AS IT IS.
PLEASE DO NOT REPRODUCE, REPUBLISH, CHANGE OR COPY.
2
Zgłoś jeśli naruszono regulamin