0% found this document useful (0 votes)
11 views

Introduction To Object-Oriented Programming

Uploaded by

anamol pradhan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Introduction To Object-Oriented Programming

Uploaded by

anamol pradhan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

C# PROGRAMMING

Introduction to Object-Oriented Programming


OBJECT-ORIENTED
PROGRAMMING
Object-oriented programming (OOP) is a
programming paradigm that organizes data and
behavior into reusable structures called objects.
 Objects are instances of classes, which define
their properties and methods.
 OOP promotes modularity, reusability, and
extensibility.

20XX PRESENTATION TITLE 2


CONCEPTS OF OOP

Encapsulation Inheritance Polymorphism


Encapsulation is the Inheritance allows classes Polymorphism enables
bundling of data and to inherit properties and objects to take on many
methods together within a methods from other classes forms and have multiple
class behaviors.

20XX PRESENTATION TITLE 3


CLASSES
A class is a blueprint for creating objects. It defines the
properties, methods, and events that objects of the class will
have.

 Classes support encapsulation, inheritance, and


polymorphism.

 In C#, classes are reference types and are instantiated using


the 'new' keyword.
20XX PRESENTATION TITLE 4
C# METHODS
Methods in C# are blocks of code that perform a
specific task.
 They can be defined inside classes or structs.
 Methods can have parameters and return
values. They encapsulate reusable code and
promote code organization.
 C# supports different types of methods, such
as instance methods, static methods, and
extension methods.

20XX PRESENTATION TITLE 5


C# PROPERTIES

Properties provide a way to encapsulate the


internal state of a class or struct and control its
access.
 They allow you to define getters and setters to
read and write the values of private fields.
 Properties enable data abstraction and provide
a convenient way to access and modify object
data.

20XX PRESENTATION TITLE 6


CODE EXAMPLE
OF PROPERTIES
public class Stock

decimal currentPrice; // The private "backing" field

public decimal CurrentPrice // The public property

get { return currentPrice; } set { currentPrice = value;}

20XX PRESENTATION TITLE 7


TYPES OF PROPERTIES IN
C#

Read-only and calculated properties

Automatic properties

get and set accessibility

CLR property implementation

20XX PRESENTATION TITLE 8


PRESENTATION TASK

Explain all the types of


properties with proper
examples?

20XX PRESENTATION TITLE 9


STRUCTS
A struct is a value type that can encapsulate data and
related functionality.

 Structs are typically used for lightweight objects


that don't require inheritance or reference
semantics.

 Structs are passed by value, which means a copy


of the struct is created when passed to a method
or assigned to another variable.

20XX PRESENTATION TITLE 10


ENCAPSULATION
• Encapsulation is the process of bundling data and methods together
within a class. It allows you to hide the internal details and provide a
public interface for interacting with the object. Encapsulation helps in
achieving data abstraction, modularity, and code maintainability.

20XX PRESENTATION TITLE 11


INHERITANCE
• Inheritance is a mechanism that allows classes to inherit properties and
methods from other classes. It promotes code reuse and supports the
concept of generalization and specialization. In C#, classes can inherit
from a single base class, but they can implement multiple interfaces.

20XX PRESENTATION TITLE 12


POLYMORPHISM
• Polymorphism enables objects to take on many forms and have
multiple behaviors. It allows you to write code that can work with
objects of different types through a common interface. Polymorphism
is achieved through method overriding and method overloading.

20XX PRESENTATION TITLE 13

You might also like