P
P
Pavlo Ponomarenko2019-03-27 21:13:39
C++ / C#
Pavlo Ponomarenko, 2019-03-27 21:13:39

What is the new keyword in C# for immutable classes?

If I didn’t dream, then I recently saw that a new keyword is being added to c # and, if my memory serves me right, this is the word with, but I can’t find it at all. The bottom line is that this is sugar for the With method, which creates a copy of the current object with some modified parameters. Can you poke me into instructions or news?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Foggy Finder, 2019-03-27
@TheShock

What you are talking about now is called Records, which has been used successfully in F# for a long time.
The question of when their support will be added to C# is still open. Apparently it won't be included in C# 8.0. And then we'll see, as there have been rumors since C# 6.0.
The sentence includes "with-expressions" which will allow you to write the following code:
and will be equivalent
More information you can find here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question