SlideShare a Scribd company logo
Car beetle = new Car();
Object Creation - Behind the scenes
{CHEEZYCODE}
Car beetle = new Car();
class Car
{
//Properties
public int modelYear;
public string carName;
public string carType;
public float price;
//Methods
public void DriveCar()
{
Console.WriteLine("Car is driving");
}
public void ApplyBrake()
{
Console.WriteLine("Car is applying brakes");
}
}
{CHEEZYCODE}
Car beetle = new Car(); 1
class Car
{
//Properties
public int modelYear;
public string carName;
public string carType;
public float price;
//Methods
public void DriveCar()
{
Console.WriteLine("Car is driving");
}
public void ApplyBrake()
{
Console.WriteLine("Car is applying brakes");
}
} {CHEEZYCODE}
Car beetle = new Car(); 1 When we say new Car(), new
object in the memory is created.
class Car
{
//Properties
public int modelYear;
public string carName;
public string carType;
public float price;
//Methods
public void DriveCar()
{
Console.WriteLine("Car is driving");
}
public void ApplyBrake()
{
Console.WriteLine("Car is applying brakes");
}
}
{CHEEZYCODE}
Car beetle = new Car(); 1 When we say new Car(), new
object in the memory is created.
Memory Locations
{CHEEZYCODE}
Car beetle = new Car(); 1 When we say new Car(), new
object in the memory is created.
Object will occupy certain
bytes in memory
Memory Locations
{CHEEZYCODE}
Car beetle = new Car(); 1 When we say new Car(), new
object in the memory is created.
Memory Locations
{CHEEZYCODE}
Car beetle = new Car(); 1 When we say new Car(), new
object in the memory is created.
Memory Locations
{CHEEZYCODE}
Car beetle = new Car(); 1 When we say new Car(), new
object in the memory is created.
This is new object of
Car in memory
Memory Locations
{CHEEZYCODE}
Car beetle = new Car(); 2
This is new object of
Car in memory
Memory Locations
Object has been created, now
location of this object is passed
as a reference
{CHEEZYCODE}
Car beetle = new Car(); 3
This is new object of
Car in memory
Memory Locations
Location of this object is stored in
beetle to access the car object
{CHEEZYCODE}
Car beetle = new Car(); 4
beetle
Memory Locations
Now you can access newly created
object in memory with the help of
beetle reference
{CHEEZYCODE}
Car beetle = new Car(); 5
beetle
What does this object has?
{CHEEZYCODE}
Car beetle = new Car(); 5
beetle
What does this object has?
class Car
{
//Properties
public int modelYear;
public string carName;
public string carType;
public float price;
//Methods
public void DriveCar()
{
Console.WriteLine("Car is driving");
}
public void ApplyBrake()
{
Console.WriteLine("Car is applying brakes");
}
}
Remember this ?
{CHEEZYCODE}
Car beetle = new Car(); 6
beetle
Object stores properties values - it
could be another object or built in
types like int or float
class Car
{
//Properties
public int modelYear;
public string carName;
public string carType;
public float price;
//Methods
public void DriveCar()
{
Console.WriteLine("Car is driving");
}
public void ApplyBrake()
{
Console.WriteLine("Car is applying brakes");
}
} {CHEEZYCODE}
7beetle beetle object in memory has
these properties
class Car
{
//Properties
public int modelYear;
public string carName;
public string carType;
public float price;
//Methods
public void DriveCar()
{
Console.WriteLine("Car is driving");
}
public void ApplyBrake()
{
Console.WriteLine("Car is applying brakes");
}
}
modelYear (Integer)
carName (String)
carType(String)
price(float)
{CHEEZYCODE}
8 What if I want to create 2 objects?
{CHEEZYCODE}
8 What if I want to create 2 objects?
Car beetle = new Car();
Car mustang = new Car();
{CHEEZYCODE}
8 What if I want to create 2 objects?
Car beetle = new Car();
Car mustang = new Car();
Same process will be followed
{CHEEZYCODE}
8 What if I want to create 2 objects?
modelYear (Integer)
carName (String)
carType(String)
price(float)
modelYear (Integer)
carName (String)
carType(String)
price(float)
beetle mustang
{CHEEZYCODE}
8
beetle
What if I want to create 2 objects?
modelYear (Integer)
carName (String)
carType(String)
price(float)
modelYear (Integer)
carName (String)
carType(String)
price(float)
mustang
BOTH
OBJECTS
ARE
DIFFERENT
{CHEEZYCODE}
9
Assign values to these properties
using dot(.) operator
beetle
modelYear (Integer)
carName (String)
carType(String)
price(float)
Assigning values to
these properties.
These are similar to
variables but they are
inside beetle and part of
beetle object.
{CHEEZYCODE}
9
Assign values to these properties
using dot(.) operator
beetle
modelYear (Integer)
carName (String)
carType(String)
price(float)
beetle.modelYear = 2017;
beetle.carName = "Volkswagen Beetle“;
beetle.carType = "Beetle 1.8T “;
beetle.price = 19795F;
{CHEEZYCODE}
10
Access these properties using dot
operator
beetle
modelYear (Integer)
carName (String)
carType(String)
price(float)
You access the
properties of beetle
using dot operator
{CHEEZYCODE}
10
Assign values to these properties
using dot(.) operator
beetle
modelYear (Integer)
carName (String)
carType(String)
price(float)
Console.WriteLine(beetle.modelYear);
and similarly you access other
properties of object
{CHEEZYCODE}
Classes And Objects
This is how it works behind the scenes
{CHEEZYCODE}
{CHEEZYCODE}
WE ARE SOCIAL
SUBSCRIBE

More Related Content

PDF
VR Workshop #2
PDF
C# and Dot Net by Example
DOC
C# example (Polymorphesim)
PPT
14. Defining Classes
PPT
20. Object-Oriented Programming Fundamental Principles
PDF
Oop in java script
DOCX
Software Engineer Screening Question - OOP
PDF
Driverimport java.util.Scanner;A class that keeps a f.pdf
VR Workshop #2
C# and Dot Net by Example
C# example (Polymorphesim)
14. Defining Classes
20. Object-Oriented Programming Fundamental Principles
Oop in java script
Software Engineer Screening Question - OOP
Driverimport java.util.Scanner;A class that keeps a f.pdf

Similar to Classes and Objects In C# With Example (20)

PPTX
14. Java defining classes
PDF
For the following questions, you will implement the data structure to.pdf
DOCX
OOP and C++Classes
PDF
C#i need help creating the instance of stream reader to read from .pdf
PDF
(7) cpp abstractions inheritance_part_ii
PPTX
object oriented programming with C++ Constructors_Destructors.pptx
PDF
I need to do the followingAdd a new item to the inventory m.pdf
PPTX
Optional in Java 8
PDF
This is my visual studio C code how do I make it so that w.pdf
PDF
C# Programming Help
PDF
JavaScript Core
PDF
Create a system to simulate vehicles at an intersection. Assume th.pdf
PDF
Decorator design pattern (A Gift Wrapper)
PDF
Unit4_2.pdf
PDF
(5) c sharp introduction_object_orientation_part_ii
PDF
Protocol-Oriented Programming in Swift
PDF
Java doc Pr ITM2
DOCX
#include iostream#include string#include iomanip#inclu.docx
PDF
In C#, visual studio, I want no more text boxes added, I have button.pdf
DOCX
Public class race track {public static void main(string[] args
14. Java defining classes
For the following questions, you will implement the data structure to.pdf
OOP and C++Classes
C#i need help creating the instance of stream reader to read from .pdf
(7) cpp abstractions inheritance_part_ii
object oriented programming with C++ Constructors_Destructors.pptx
I need to do the followingAdd a new item to the inventory m.pdf
Optional in Java 8
This is my visual studio C code how do I make it so that w.pdf
C# Programming Help
JavaScript Core
Create a system to simulate vehicles at an intersection. Assume th.pdf
Decorator design pattern (A Gift Wrapper)
Unit4_2.pdf
(5) c sharp introduction_object_orientation_part_ii
Protocol-Oriented Programming in Swift
Java doc Pr ITM2
#include iostream#include string#include iomanip#inclu.docx
In C#, visual studio, I want no more text boxes added, I have button.pdf
Public class race track {public static void main(string[] args
Ad

Recently uploaded (20)

PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Introduction to Artificial Intelligence
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
medical staffing services at VALiNTRY
PDF
System and Network Administraation Chapter 3
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
assetexplorer- product-overview - presentation
PDF
Digital Strategies for Manufacturing Companies
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
Introduction to Artificial Intelligence
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
CHAPTER 2 - PM Management and IT Context
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
medical staffing services at VALiNTRY
System and Network Administraation Chapter 3
wealthsignaloriginal-com-DS-text-... (1).pdf
Odoo Companies in India – Driving Business Transformation.pdf
Softaken Excel to vCard Converter Software.pdf
Design an Analysis of Algorithms I-SECS-1021-03
assetexplorer- product-overview - presentation
Digital Strategies for Manufacturing Companies
Which alternative to Crystal Reports is best for small or large businesses.pdf
Designing Intelligence for the Shop Floor.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Ad

Classes and Objects In C# With Example

  • 1. Car beetle = new Car(); Object Creation - Behind the scenes {CHEEZYCODE}
  • 2. Car beetle = new Car(); class Car { //Properties public int modelYear; public string carName; public string carType; public float price; //Methods public void DriveCar() { Console.WriteLine("Car is driving"); } public void ApplyBrake() { Console.WriteLine("Car is applying brakes"); } } {CHEEZYCODE}
  • 3. Car beetle = new Car(); 1 class Car { //Properties public int modelYear; public string carName; public string carType; public float price; //Methods public void DriveCar() { Console.WriteLine("Car is driving"); } public void ApplyBrake() { Console.WriteLine("Car is applying brakes"); } } {CHEEZYCODE}
  • 4. Car beetle = new Car(); 1 When we say new Car(), new object in the memory is created. class Car { //Properties public int modelYear; public string carName; public string carType; public float price; //Methods public void DriveCar() { Console.WriteLine("Car is driving"); } public void ApplyBrake() { Console.WriteLine("Car is applying brakes"); } } {CHEEZYCODE}
  • 5. Car beetle = new Car(); 1 When we say new Car(), new object in the memory is created. Memory Locations {CHEEZYCODE}
  • 6. Car beetle = new Car(); 1 When we say new Car(), new object in the memory is created. Object will occupy certain bytes in memory Memory Locations {CHEEZYCODE}
  • 7. Car beetle = new Car(); 1 When we say new Car(), new object in the memory is created. Memory Locations {CHEEZYCODE}
  • 8. Car beetle = new Car(); 1 When we say new Car(), new object in the memory is created. Memory Locations {CHEEZYCODE}
  • 9. Car beetle = new Car(); 1 When we say new Car(), new object in the memory is created. This is new object of Car in memory Memory Locations {CHEEZYCODE}
  • 10. Car beetle = new Car(); 2 This is new object of Car in memory Memory Locations Object has been created, now location of this object is passed as a reference {CHEEZYCODE}
  • 11. Car beetle = new Car(); 3 This is new object of Car in memory Memory Locations Location of this object is stored in beetle to access the car object {CHEEZYCODE}
  • 12. Car beetle = new Car(); 4 beetle Memory Locations Now you can access newly created object in memory with the help of beetle reference {CHEEZYCODE}
  • 13. Car beetle = new Car(); 5 beetle What does this object has? {CHEEZYCODE}
  • 14. Car beetle = new Car(); 5 beetle What does this object has? class Car { //Properties public int modelYear; public string carName; public string carType; public float price; //Methods public void DriveCar() { Console.WriteLine("Car is driving"); } public void ApplyBrake() { Console.WriteLine("Car is applying brakes"); } } Remember this ? {CHEEZYCODE}
  • 15. Car beetle = new Car(); 6 beetle Object stores properties values - it could be another object or built in types like int or float class Car { //Properties public int modelYear; public string carName; public string carType; public float price; //Methods public void DriveCar() { Console.WriteLine("Car is driving"); } public void ApplyBrake() { Console.WriteLine("Car is applying brakes"); } } {CHEEZYCODE}
  • 16. 7beetle beetle object in memory has these properties class Car { //Properties public int modelYear; public string carName; public string carType; public float price; //Methods public void DriveCar() { Console.WriteLine("Car is driving"); } public void ApplyBrake() { Console.WriteLine("Car is applying brakes"); } } modelYear (Integer) carName (String) carType(String) price(float) {CHEEZYCODE}
  • 17. 8 What if I want to create 2 objects? {CHEEZYCODE}
  • 18. 8 What if I want to create 2 objects? Car beetle = new Car(); Car mustang = new Car(); {CHEEZYCODE}
  • 19. 8 What if I want to create 2 objects? Car beetle = new Car(); Car mustang = new Car(); Same process will be followed {CHEEZYCODE}
  • 20. 8 What if I want to create 2 objects? modelYear (Integer) carName (String) carType(String) price(float) modelYear (Integer) carName (String) carType(String) price(float) beetle mustang {CHEEZYCODE}
  • 21. 8 beetle What if I want to create 2 objects? modelYear (Integer) carName (String) carType(String) price(float) modelYear (Integer) carName (String) carType(String) price(float) mustang BOTH OBJECTS ARE DIFFERENT {CHEEZYCODE}
  • 22. 9 Assign values to these properties using dot(.) operator beetle modelYear (Integer) carName (String) carType(String) price(float) Assigning values to these properties. These are similar to variables but they are inside beetle and part of beetle object. {CHEEZYCODE}
  • 23. 9 Assign values to these properties using dot(.) operator beetle modelYear (Integer) carName (String) carType(String) price(float) beetle.modelYear = 2017; beetle.carName = "Volkswagen Beetle“; beetle.carType = "Beetle 1.8T “; beetle.price = 19795F; {CHEEZYCODE}
  • 24. 10 Access these properties using dot operator beetle modelYear (Integer) carName (String) carType(String) price(float) You access the properties of beetle using dot operator {CHEEZYCODE}
  • 25. 10 Assign values to these properties using dot(.) operator beetle modelYear (Integer) carName (String) carType(String) price(float) Console.WriteLine(beetle.modelYear); and similarly you access other properties of object {CHEEZYCODE}
  • 26. Classes And Objects This is how it works behind the scenes {CHEEZYCODE}