Learn C#: References
Unlock the power of references: an essential aspect of object-oriented programming in C#.
StartKey Concepts
Review core concepts you need to learn to master this subject
C# Reference Types
C# Object Reference
C# Object Reference Functionality
C# Polyphormism
C# Upcasting
C# Downcasting
C# Null Reference
C# Value Types
C# Reference Types
C# Reference Types
SportsCar sc = new SportsCar(100);
SportsCar sc2 = sc;
sc.SpeedUp(); // Method adds 20
Console.WriteLine(sc.Speed); // 120
Console.WriteLine(sc2.Speed); // 120
// In this code, sc and sc2 refer to the same object. The last two lines will print the same value to the console.
In C#, classes and interfaces are reference types. Variables of reference types store references to their data (objects) in memory, and they do not contain the data itself.
An object of type Object
, string
, or dynamic
is also a reference type.
Reference Fundamentals
Lesson 1 of 3
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory