Any more C# 10 you want to know about? Let me know. Source code at: github.com/JasperKent/CSharp-10-Part-2 Remember to subscribe at ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html And if you liked the video, don't forget to click the 👍.
It's hard to be definite about. I don't use structs much, so I don't use record structs much. But my instinct is, if you're going to write a struct, make it a record struct, then you're helped with immutability and given all the free methods.
@@SharafMansour They do. But by using the positional syntax (putting the properties in brackets after the record name) you are declaring a constructor with parameters. And so, just like with a class, adding any constructor turns off the auto-generation of a default constructor.
Any more C# 10 you want to know about? Let me know.
Source code at: github.com/JasperKent/CSharp-10-Part-2
Remember to subscribe at ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
And if you liked the video, don't forget to click the 👍.
This channel should be top... great content and solid lessons. Thanks!
I hope that with C# 11 we'll finally get union types🤞
Very nice explanation... thanks
Can you tell me where are the use cases for record structs ?
It's hard to be definite about. I don't use structs much, so I don't use record structs much. But my instinct is, if you're going to write a struct, make it a record struct, then you're helped with immutability and given all the free methods.
Would not it be useful to have a default constructor for record class ?
Yes, you can add one to a record class if you want.
@@CodingTutorialsAreGo I mean getting one out of the box. Like in normal class.
Trying to understand C# team POV. When record classes came without a default constructor. I have to manually define them.
@@SharafMansour They do. But by using the positional syntax (putting the properties in brackets after the record name) you are declaring a constructor with parameters. And so, just like with a class, adding any constructor turns off the auto-generation of a default constructor.