Press "Enter" to skip to content

Object Deconstruction in C#

Patrick Smacchia shows off a feature in C#:

C# 7.0 introduced the deconstruction syntax. It allows developers to extract in a single expression, properties of an object or elements of a tuple and then to assign them to distinct variables . Here is a small program candidate to be simplified with deconstruction:

I enjoy (more than I should) being able to say “C# got this from F#.” Object deconstruction is quite useful and it’s good to see that the C# syntax is close to what we get in F# or Python.