Follow me on Twitter, happy to take your suggestions on topics or improvements /Chris
So I've been out of the loop for a while. I've actually bee...
For further actions, you may consider blocking this person and/or reporting abuse
Great! I like tuples and records. Another feature I like is inline variable declaration with
out
parameters. I think for pattern matching, sometimes casting isn't needed, for exampleif (character is Hero h)
. I would like to read this kind of posts for Php.thank you for your comment Cesar. Appreciate you sharing your likes as well. Not a Php dev I'm afraid
Record types are one of my most highly anticipated features having used them in Kotlin (where they are known as data classes). Cutting out the Equals/GetHashCode boilerplate will be extremely useful.
The switch expression from C# 8 has been one of my most used new features since updating, the only disadvantage is that when you have multiple branches that should have the same resulting value you have to provide each branch separately rather than batching them together. Ideally Iβd like to write something like:
Another handy recent addition from C# 8 are indices and ranges: docs.microsoft.com/en-us/dotnet/cs... - Iβve found these especially useful when working with the
Span<T>
types!about your switch there I believe if you just write it like so (1,2,3) => "result", you can achieve what you want.. Thanks for sharing Euan
Good writeup, Chris. I am very much looking forward to record types and I hope that Microsoft will keep bringing good functional ideas from languages such as F# into C#.
thank you Jacob :)
Really thanks for this article, great!
Thank you
Need to read this again at some point. Hence the bookmark. Am thinking most of this is useful when using the C# interactive mode?
Could be. I mean evaluating pattern matching, I can see how that can be useful... or Deconstruct an object.. :)
Have bookmarked it - so when I have a chance will have a play around. Cheers.
I like C# but I have to confess that I prefer how to destructing in JS works than C#. it is very simple and you don't have to make a lot of effort to achieve it.
thank you for your feedback Miguel. I agree with this in principle, it should be easy. It would surprise me a lot though if the C# team wasn't trying to improve this over time..
As always, you wrote an excellent article. Thanks!
thank you cristian, appreciated :)