How Do Virtual Functions Work? [1 of 4] | Understanding the .NET CLR

Описание к видео How Do Virtual Functions Work? [1 of 4] | Understanding the .NET CLR

Become a patron and get access to source code and exclusive live streams:   / how-do-virtual-81379027  

Rebuilding the .NET Runtime mini-series:
1. How Do Virtual Functions Work? ►    • How Do Virtual Functions Work? [1 of ...  
2. How Does C# Resolve Virtual Functions? ►    • How Does C# Resolve Virtual Functions...  
3. .NET Runtime and Resolution of Object's Type and Virtual Functions ►    • How Does .NET Runtime Resolve Object'...  
4. Reimplementing .NET Runtime for Learning and Fun ►    • Reimplementing .NET Runtime for Learn...  

In this video, we are tackling the question of dynamic resolution of virtual functions at run time, performed from an object, rather than from its statically declared reference type which available at compile time.

In the demo code, we will define a base class with a virtual function, and a derived class which overrides the function inherited from the base. When instances of both classes are assigned to a reference to the base class, compiler cannot determine which function implementation to invoke when a call is made on the reference.

We must wait until run time, where a specially designed .NET Runtime function will inspect the object pointed to by the reference, in order to discover whether it contains an override of the virtual function, or the call should be pointed back to the original implementation from the base class.

Learn more from video courses:
Beginning Object-oriented Programming with C# ► https://codinghelmet.com/go/beginning...
Collections and Generics in C# ► https://codinghelmet.com/go/collectio...
Making Your C# Code More Object-oriented ► https://codinghelmet.com/go/making-yo...

Other courses at Pluralsight ► https://codinghelmet.com/go/pluralsight
Other courses at Udemy ► https://codinghelmet.com/go/udemy

Other videos on this channel you may be interested in watching:
Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial ►    • Using GitHub Copilot to Write Complex...  
Coding with GitHub Copilot - Beginner to Master | VS Code Demo ►    • A Comprehensive Guide to GitHub Copil...  
What is Covariance and Contravariance in C# ►    • What is Covariance and Contravariance...  
How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity ►    • How to Initialize a Clean ASP.NET Cor...  
The Null Conundrum: A Guide to Optional Objects in C# ►    • How to Avoid Null Reference Exception...  

Комментарии

Информация по комментариям в разработке