Search code examples
c#c#-4.0language-featuresanonymous-typestuples

Anonymous type and tuple


What is the difference between anonymous type and tuple?


Solution

  • Anonymous types have property names which carry more information, for tuples you don't have this. You can't use anonymous types as return values and parameters though and you can with tuples.

    An example of when a tuple is nice is when you want to return multiple values. @Petar Minchev mentions this link which gives a good example.

    You may want a Find() method that returns both an index and the value. Another example would be the position in a 2d or 3d plane.