using System.Collections.Generic;
public static void Main()
var fooArray = new List<Foo>()
valueOne = "Equal Value",
valueOne = "Equal Value",
valueTwo = "Different value"
valueOne = "Equal Value",
valueOne = "SomeOtherValue",
valueOne = "I have null value, but should still be in list",
var fooResult = fooArray.Distinct();
public class Foo : IEquatable<Foo>
public int Code { get; set;}
public bool Equals(Foo other)
if(this.valueOne == other.valueOne && this.valueTwo == (other.valueTwo ?? this.valueTwo))
public override int GetHashCode()
int hashCode = Code.GetHashCode();