An abstract replacement for .net Tuples.
abstract, built for descending from with:- No
publicmembers - Simple and correct
EqualsandGetHashCodeimplementation - 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>:
Item1andItem2areprotected, keeping intellisense clean and they shouldn't appear with most serializers.Equalsand/orGetHashCodecould be overridden if required without breaking contract.- The hash is cached for performance