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.


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?

  • Possible duplicate of Why do 'some examples' and 'list of things' questions get closed? – gnat Mar 8 '17 at 20:36
  • 1
    Opposed to gnat, I think this one would probably ok. But the canonical answer is IMHO so trivial it fits into this comment: "semantically, this is equivalent to using 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
  • 2
    ... however, asking if this new feature "encourages bad practices" will make the question a candidate for closing as "primarily opinionated". Same argument for "why did Microsoft include this feature in C#7" - you will get the answer "we don't know, ask Eric Lippert directly". – Doc Brown Mar 8 '17 at 21:50
  • @DocBrown Good call on the "does it encourage bad practice". I agree that would make it opinion based. – BanksySan Mar 8 '17 at 22:31
  • 1
    The answer to your question "what benefit does the anonymous tuple give me" is brevity. – Robert Harvey Mar 10 '17 at 17:15

Questions about language design can be problematic: it is too easy to fall into one of several close reasons:

  • Too broad. You would need to scope the question quite tightly. I know from experience looking at blogs and other web sites that discuss new versions of languages that there can be a ton of information: far more than is reasonable to fit in an answer here.

  • Primarily opinion-based. Depending on the feature and how it is used, people may approve or disapprove of a feature. For example: consider if the ternary operator (expr ? if-true : if-false) were just now being added to a language. This would invite highly-opinionated arguments similar to tabs-vs-spaces. I would hope that by 2017 new features are more clearly beneficial and less opinionated, but this is not always the case.

    This actually gets at the heart of your question: you have concerns about some of the features, and are likely looking for opinions and discussion, both of which will result in question closure.

  • Off-topic: resource recommendation. Do not ask for links to sites that explain new features.

Even if you craft a great question that avoids these pitfalls, you will likely meet quite a bit of resistance from the community as many of the users who have enough reputation to cast close votes and are active daily have a bias against questions like this. Even if you have a great question, it has been preceded by a line of utter crap that has predisposed the community toward erring on the side of closing.

Honestly, you are probably better off asking on reddit. Maybe there is already a thread about it there?

See Also


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .