Dotnet Tutorial Abstractions Slides

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

.

NET Framework Tutorial


Part 2: Abstractions

Abstraction mechanisms
The .NET Framework has support for many types of abstractions Core abstraction mechanisms include
Interfaces Inheritance Delegates and Events

How late binding works in the .NET Framework


Variable is of type ICar
ICar car = new M3(); car.Start();

Object in heap is of type M3

how is this dispatched?

Objects (technically reference types) have a object header


Current implementation requires 8 bytes

Header contains bookkeeping info for the CLR


Type handle Sync handle Bit flags for the garbage collector, etc.

The type handle tells the CLR the type of the object

Value types
Int32 and Double are examples of value types They do not have an object header If used like an object, they will be copied and wrapped into the heap
This is known as boxing and unboxing

In C#, use the struct keyword to create a value type


This is a performance optimization Helpful where large arrays of these values are used Cannot use inheritance

You might also like