title: Any tips to make working with Tuples easier in C#?
body: <p>Often you want to send multiple values but due to low use (i.e. it is only used in one or two places), it's hard to justify creating a new type.</p>
  
  <p>The <code>Tuple&lt;...&gt;</code> and <code>KeyValuePair&lt;,&gt;</code> type are very useful, but there isn't real language support for them. </p>
  
  <p>Well sort of, a nice trick to use for Lists of tuples is to create a type that extends the List and adding a custom add method:
  e.g.</p>
  
  <pre><code>public class TupleList&lt;T1,T2&gt; : List&lt;Tuple&lt;T1,T2&gt;&gt;{
      public void Add(T1 key, T2 value){
          base.Add(Tuple.Create(key, value));
      }
  }
  </code></pre>
  
  <p>This means that if I have a method that takes an <code>IEnumerable&lt;Tuple&lt;int,string&gt;&gt;</code>, I can use the following code to quickly build up the list like so::</p>
  
  <pre><code>Foo(new TupleList&lt;int,string&gt;{{1,"one"},{2,"two"},{3,"three"}});
  </code></pre>
  
  <p>This makes winding values into a tuple list easier as we don't have to constantly keep saying <code>Tuple.Create</code>, and gets us almost to a nice functional languages syntax.</p>
  
  <p>But when working with a tuple it is useful to unwind it out into its different components. This extension method might be useful in this respect::</p>
  
  <pre><code>    public static void Unwind&lt;T1,T2&gt;(this Tuple&lt;T1,T2&gt; tuple,out T1 var1,out T2 var2)
      {
          var1 = tuple.Item1;
          var2 = tuple.Item2;
      }
  </code></pre>
  
  <p>But even that's annoying as out parameters are not variant at all. That is if T1 is a string, I can't send in an object variable even though they are assignable, when as I can do the unwinding by hand otherwise. I can't really suggest a reason why you might want this variance, but if its there, I can't see why you would want to lose it.</p>
  
  <p>Anyone have other tips to making working tuples, or tuple like objects easier in C#?</p>
  
  <p>An important potential use for tuples might be generic memoization. Which is very easy in languages like F#, but hard in C#.</p>
  
  <p>I'm currently using Tuples to supply a MethodBase and an array of tokens (constants, objects, or argument tokens), supplied to a dynamicly built object to construct certain member fields.</p>
  
  <p>Since I wanted to make the syntax easier on API consumers, I created Add methods that can take a <code>ConstructorInfo</code> or a <code>MethodInfo</code> and a params array of objects.</p>
  
  <p>Edit:
  Eric Lippert as usual has excellent motivation for using Tuples here and he even says what I suspected there really is no support:
  <a href="https://stackoverflow.com/questions/3089706/what-problem-was-the-tuple-designed-to-solve/3089883#3089883">What requirement was the tuple designed to solve?</a></p>