0% found this document useful (0 votes)
0 views17 pages

Chapter 8

This document provides an overview of Object-Oriented Programming (OOP) in C#, highlighting its advantages over procedural programming, such as improved execution speed, code structure, and maintainability. It explains the fundamental concepts of classes and objects, describing classes as blueprints for creating objects that encapsulate data and methods. The document also emphasizes the importance of using multiple classes for better organization in C# programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views17 pages

Chapter 8

This document provides an overview of Object-Oriented Programming (OOP) in C#, highlighting its advantages over procedural programming, such as improved execution speed, code structure, and maintainability. It explains the fundamental concepts of classes and objects, describing classes as blueprints for creating objects that encapsulate data and methods. The document also emphasizes the importance of using multiple classes for better organization in C# programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

C# OOP

Object-Oriented Programming.
C# - What is OOP?
OOP stands for Object-Oriented Programming.

Procedural programming is about writing procedures or


methods that perform operations on the data, while
object-oriented programming is about creating objects
that contain both data and methods.
Object-oriented programming has several advantages over
procedural programming:

• OOP is faster and easier to execute


• OOP provides a clear structure for the programs
• OOP helps to keep the C# code DRY "Don't Repeat Yourself", and
makes the code easier to maintain, modify and debug
• OOP makes it possible to create full reusable applications with
less code and shorter development time
C# - What are Classes and Objects?
• Classes and objects are the two main aspects of object-
oriented programming.
C# - What are Classes and Objects?
• Classes and objects are the two main aspects of object-
oriented programming.
C# Classes and Objects
• Everything in C# is associated with classes and objects,
along with its attributes and methods. For example: in
real life, a car is an object. The car has attributes,
such as weight and color, and methods, such as drive
and brake.

• A Class is like an object constructor, or a "blueprint" for


creating objects.
Create an Object
C# Multiple Classes and Objects
Using Multiple Classes
C# Class Members
Fields and methods inside classes are often referred to as "Class Members":
Fields
You can also leave the fields blank, and modify them when creating the object:
Object Methods
Object Methods
Use Multiple Classes
Remember from the last chapter, that we can use multiple classes for better organization
(one for fields and methods, and another one for execution). This is recommended:
Use Multiple Classes

You might also like