From the course: .NET 9 Maui: Enhanced Features for Cross-Platform Development
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Enable ref struct types to implement interfaces
From the course: .NET 9 Maui: Enhanced Features for Cross-Platform Development
Enable ref struct types to implement interfaces
- [Instructor] A C# structure is a value type that can track multiple values and associated functionality. However, it is not a reference type. That means it can't do boxing or unboxing operations, nor can a structure participate in inheritance as a base or derived class. But in many ways, a structure can be thought of as a lightweight, high performing class. A ref structure is a type of structure that takes another step down that road. It is treated in memory differently than a standard structure or reference type. In memory, a ref structure lives exclusively on the stack and cannot be moved to the managed heap. This means it is much faster to reference and release memory it resides in. However, the ref structure came with some limitations. One of them being that it could not implement interfaces like a normal structure. With C# 13, this has changed and ref structures can now implement interfaces. It is still a value type instead of a reference type, so it can't undergo boxing. In…
Contents
-
-
-
-
-
-
(Locked)
Params collections4m 6s
-
(Locked)
New lock type and semantics3m 53s
-
(Locked)
New escape sequence: \e1m 48s
-
(Locked)
Method group natural type improvements4m 18s
-
(Locked)
Implicit indexer access in object initializers2m 49s
-
(Locked)
Enable ref locals and unsafe contexts in iterators and async methods3m 55s
-
(Locked)
Enable ref struct types to implement interfaces4m 43s
-
(Locked)
Allow ref struct types as arguments for type parameters in generics5m 50s
-
(Locked)
Partial properties and indexers6m 21s
-
(Locked)
Overload resolution priority4m 4s
-
(Locked)
-
-