Supertuples

Super Tuples

View project on GitHub

Super Tuples

NuGet Build Status

An abstract replacement for .net Tuples.

Key Features

  1. abstract, built for descending from with:
  2. No public members
  3. Simple and correct Equals and GetHashCode implementation
  4. Optional cached hash

Example

public class Person : Suple<string, string>
{
    public Person(string firstName, string lastName)
        : base(firstName, lastName, SupleHash.Cached)
    {
    }

    public string FirstName => Item1;
    public string LastName => Item2;
}

Person fully supports a correct equality contract, much like inheriting from Tuple<string, string>, but unlike inheriting from Tuple<string, string>:

  1. Item1 and Item2 are protected, keeping intellisense clean and they shouldn't appear with most serializers.
  2. Equals and/or GetHashCode could be overridden if required without breaking contract.
  3. The hash is cached for performance