Oop 2
Oop 2
● They are typically compiled into dynamic link libraries (DLL) and
2. Struct 1. Internal
3. Interface 2. Public
4. Enum
Modifier?
User Defined Data
Type
Interface
What You Can Write Inside ?
Internal
Access Modifiers
● They are keywords used to define the accessibility of types
(Ex: classes, structs, enums and Interfaces) and their members (Ex
: fields, properties, methods, etc.).
1. Private
2. Private Protected
3. Protected
4. Internal
5. Protected Internal
6. Public
Access Modifiers
1. Private
Accessibility: The member is only accessible within the class or struct it is defined in. It cannot be accessed from outside the
class.
Usage: Use for members that should only be accessible within the class, often for internal implementation details.
2. Internal
Accessibility: The member is accessible only within the same assembly . It is not accessible outside the project, even in derived
classes.
Usage: Use when you want the member to be accessible only within the same project/assembly, but not from other projects or
3. Public
libraries.
Accessibility: The member is accessible from anywhere in the application, both within the same assembly (project) and from other
assemblies.
Struct
● Struct is (stand for "structure") is a value type meaning That they are
● As they are stored on stack that making them more lightweight for
● They are commonly used to represent small, simple objects that do not
P1.X = 10; 8
X 10
0
Bytes
P1.Y = 20; Y 20
0
Stack
Struct
Point P1 = new Point() ;
X 100
10
P2 8
Point P2 = new Point(100 , 200); Bytes
Y 200
20
P2 = P1;
P1.X = 500;
X 10
500
Console.WriteLine(P1.x); // 500 P1 8
Y 20 Bytes
Console.WriteLine(P2.x); // 10
Stack
Struct
Summary
● Value Type Stored in Stack
● This protects the internal data and ensures that it can only be
modified in a controlled way.
OOP Definition
Inheritance :
● It allows a class (called a derived class or child class) to
● Overriding
OOP Definition
Abstraction :
● It is the process of hiding the complex implementation details and only
does it.
Encapsulation
Separate Data Definition [Attributes] From Its Use [Getter Setter ,
Property]
Encapsulation
Properties :
Property where you can define the get and set accessors with custom business logic,
1. make
Fullyou
Property
have more control over how values are retrieved or assigned
The C# compiler generates private backing fields for these properties behind the
2. Automatic Property
scenes