filmov
tv
C# 9 - Record Types Introduction & Deep-Dive

Показать описание
Record types are immutable reference types that provide value semantics for equality. Don't worry - record types aren't as complicated as they sound. Let's break it all down and see what record types are, how to implement them in C# 9, and why we should care about them.
Record types are introduced in C# 9 to allow developers to write immutable reference types. It means that the properties of an instance of a reference type cannot change after its initialization.
If we want to change the value of an existing object's property, we need to create a new instance. It is possible to inherit from a record type.
Record Types offer the following features:
- Immutability through read-only properties
- A constructor with properties as arguments
- Value-based equality checks
- A textual representation (ToString)
- A Deconstruct method
Record types are essentially a compiler feature. The developer writes a record type definition, and during compilation, the compiler generates a class based on a template.
Every situation where we could take advantage of one of the features record types provide is a potential use case for using record types instead of writing a class.
00:00 Introduction
00:33 Record Types Introduction
01:47 Cloning a record type
02:11 Record Types Inheritance
02:59 Value-based Equality
04:26 ToString Implementation
05:28 Record Types Internals - Generated Code (Advanced)
06:53 Record Types Features
08:12 Alternative Syntax
10:32 Alternative Syntax: Properties without init-setters
11:00 Alternative Syntax: Properties with default-setters
11:30 Alternative Syntax: Summary
12:05 Record Types: Add custom methods
12:33 Record Types: Use cases
13:49 Record Types: Conclusion
🔥 C#/.NET Bootcamp: The Fundamentals & more (Code FRIENDS10 for 10% OFF)*
📌 .NET Developer Roadmap
📌 YouTube Playlists:
📌 SharpLab:
✅ SUBSCRIBE FOR MORE VIDEOS
🚀 CONNECT & SUPPORT
CREDITS
* Affiliate Link: I earn a small commission at no additional cost
Record types are introduced in C# 9 to allow developers to write immutable reference types. It means that the properties of an instance of a reference type cannot change after its initialization.
If we want to change the value of an existing object's property, we need to create a new instance. It is possible to inherit from a record type.
Record Types offer the following features:
- Immutability through read-only properties
- A constructor with properties as arguments
- Value-based equality checks
- A textual representation (ToString)
- A Deconstruct method
Record types are essentially a compiler feature. The developer writes a record type definition, and during compilation, the compiler generates a class based on a template.
Every situation where we could take advantage of one of the features record types provide is a potential use case for using record types instead of writing a class.
00:00 Introduction
00:33 Record Types Introduction
01:47 Cloning a record type
02:11 Record Types Inheritance
02:59 Value-based Equality
04:26 ToString Implementation
05:28 Record Types Internals - Generated Code (Advanced)
06:53 Record Types Features
08:12 Alternative Syntax
10:32 Alternative Syntax: Properties without init-setters
11:00 Alternative Syntax: Properties with default-setters
11:30 Alternative Syntax: Summary
12:05 Record Types: Add custom methods
12:33 Record Types: Use cases
13:49 Record Types: Conclusion
🔥 C#/.NET Bootcamp: The Fundamentals & more (Code FRIENDS10 for 10% OFF)*
📌 .NET Developer Roadmap
📌 YouTube Playlists:
📌 SharpLab:
✅ SUBSCRIBE FOR MORE VIDEOS
🚀 CONNECT & SUPPORT
CREDITS
* Affiliate Link: I earn a small commission at no additional cost
Комментарии