private static string DescribeFruit(Fruit fruit) { // Matching a Fruit value to a string value return fruit.Match<Fruit, string>() .With(f => f.Description.Length > 20, "That's a long description") .With(new Apple("Granny Smith"), "My favorite :)") .WithType<Apple>("An apple") .WithType<Banana>("A banana") .WithNull("Not a fruit") .Finally("Huh?"); }
protected bool Equals(Fruit other) { return(string.Equals(_description, other._description)); }
protected bool Equals(Fruit other) { return string.Equals(_description, other._description); }