title: What's the best way of using a pair (triple, etc) of values as one value in C#?
body: <p>That is, I'd like to have a tuple of values.</p>
  
  <p>The use case on my mind:</p>
  
  <pre><code>Dictionary&lt;Pair&lt;string, int&gt;, object&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Dictionary&lt;Triple&lt;string, int, int&gt;, object&gt;
  </code></pre>
  
  <p>Are there built-in types like Pair or Triple? Or what's the best way of implementing it?</p>
  
  <p><strong>Update</strong> There are some general-purpose tuples implementations described in the answers, but for tuples used as keys in dictionaries you should additionaly verify correct calculation of the hash code. Some more info on that in another <a href="https://stackoverflow.com/questions/102690/how-does-c-figure-out-the-hash-code-for-an-object">question</a>.</p>
  
  <p><strong>Update 2</strong> I guess it is also worth reminding, that when you use some value as a key in dictionary, it should be immutable.</p>