Extension Types for Zero-Cost Wrappers
Wrap a type without runtime overhead.
A Different Tool
An extension type is a newer feature: it wraps an existing type to give it a fresh interface, with no runtime cost.
Wrap Without Boxing
Unlike a real wrapper class, an extension type adds no object at runtime. At runtime it simply is the underlying value.
extension type UserId(int id) {}All lessons in this course
- Writing Your First Extension
- Extensions on Generics
- Static Extension Members and Conflicts
- Extension Types for Zero-Cost Wrappers