What is Record in C#?
What is Record in C#?
A record in C#, introduced in C# 9.0, is a reference type that provides a concise way to define immutable data structures. Records are designed to make it easier to work with data-centric types, such as those used in data transfer objects (DTOs) or value objects.
Here are the key features of records in C#:
Records are immutable by default, meaning that once created, their properties cannot be changed. This helps prevent unintended modifications and promotes thread safety.
Records have a more concise syntax compared to traditional classes. They allow you to define properties directly in the record declaration, without the need for separate property declarations.
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.