I have some concerns about some of the new features in C# 7.
To me they seem to encourage bad practices or solve very minor problems. I'd like to ask people for some practical examples of when certain features would be applicable, best practice and save time or add some other value.
Would a carefully crafted question on this be valid here?
I'm not asking people's opinions exactly, but am asking for definate examples of coding situations where these new features help.
Cheers
Thanks for the hint at the other question. That's not really what I'm asking (I don't think).
Here's an example of a question I might ask:
What problem does returning anonymous tuples solve
One of the new C# 7 features is the ability to return multiple values from a method. In the past this problem has always been addressed by creating a class\struct encapsulating the result and returning that.
This method means that the returned information is all related and has a semantic meaning described by the class.
What benefit does the tuple give me over this (from What's new in C# 7)?
(string, string, string) LookupName(long id) // tuple return type { ... // retrieve first, middle and last from data storage return (first, middle, last); // tuple literal }
Is there any practical case in a production system where I would prefer a tuple over a class\struct?
Tuple<T1,...,Tn>
, syntactically, this is better readable since it requires less boilerplate code". And that's it - don't expect much more behind this new feature. – Doc Brown Mar 8 '17 at 21:41