Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>If we could upgrade our version of .Net, I would just return a Tuple&lt;>, but that's not going to be an option for some time yet.</p> </blockquote> <p>Why wait? It's not like a tuple is a complicated thing. Here's the code for a 3-tuple.</p> <pre><code>public struct Tuple&lt;TItem1, TItem2, TItem3&gt; { public Tuple(TItem1 item1, TItem2 item2, TItem3 item3) { this = new Tuple&lt;TItem1, TItem2, TItem3&gt;(); Item1 = item1; Item2 = item2; Item3 = item3; } public static bool operator !=(Tuple&lt;TItem1, TItem2, TItem3&gt; left, Tuple&lt;TItem1, TItem2, TItem3&gt; right) { return left.Equals(right); } public static bool operator ==(Tuple&lt;TItem1, TItem2, TItem3&gt; left, Tuple&lt;TItem1, TItem2, TItem3&gt; right) { return !left.Equals(right); } public TItem1 Item1 { get; private set; } public TItem2 Item2 { get; private set; } public TItem3 Item3 { get; private set; } public override bool Equals(object obj) { if (obj is Tuple&lt;TItem1, TItem2, TItem3&gt;) { var other = (Tuple&lt;TItem1, TItem2, TItem3&gt;)obj; return Object.Equals(Item1, other.Item1) &amp;&amp; Object.Equals(Item2, other.Item2) &amp;&amp; Object.Equals(Item3, other.Item3); } return false; } public override int GetHashCode() { return ((this.Item1 != null) ? this.Item1.GetHashCode() : 0) ^ ((this.Item2 != null) ? this.Item2.GetHashCode() : 0) ^ ((this.Item3 != null) ? this.Item3.GetHashCode() : 0); } } </code></pre> <p>As you can see, it's no big deal. What I've done on my current project is implement 2, 3 and 4-tuples, along with a static <code>Tuple</code> class with <code>Create</code> methods on it, which exactly mirror the .NET 4 tuple types. If you're really paranoid you can use reflector to look at the dissassembled source code for the .NET 4 tuple, and copy it verbatim</p> <p>When we eventually upgrade to .NET 4, we'll just delete the classes, or <code>#ifdef</code> them out</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload