An abstract replacement for .net Tuples.
abstract
, built for descending from with:- No
public
members - Simple and correct
Equals
andGetHashCode
implementation - Optional cached
hash
- Verifiably Immutable
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>
:
Item1
andItem2
areprotected
, keeping intellisense clean and they shouldn't appear with most serializers.Equals
and/orGetHashCode
could be overridden if required without breaking contract.- The hash is cached for performance