How to Achieve Immutable DTOs With C#by@igorlopushko
1,452 reads

How to Achieve Immutable DTOs With C#

tldt arrow
Read on Terminal Reader🖨️
JS🚫

Too Long; Didn't Read

In object-oriented and functional programming, an object cannot be modified after it is created. Immutable objects are also useful because they are inherently thread-safe. The question of whether or not DTOs should be immutable is a frequent question. Let’s dive in and see how immutability could be implemented with C#. We can move farther and use some syntactic sugar and use auto-properties to minimize the code. We create a simple object that represents a person and define a couple of properties.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to Achieve Immutable DTOs With C#
Igor Lopushko HackerNoon profile picture

@igorlopushko

Igor Lopushko

Learn More
LEARN MORE ABOUT @IGORLOPUSHKO'S EXPERTISE AND PLACE ON THE INTERNET.
react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa