コード例 #1
0
ファイル: Program.cs プロジェクト: bellp/PatternMatching
 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?");
 }
コード例 #2
0
ファイル: Fruit.cs プロジェクト: bellp/PatternMatching
 protected bool Equals(Fruit other)
 {
     return(string.Equals(_description, other._description));
 }
コード例 #3
0
ファイル: Fruit.cs プロジェクト: bellp/PatternMatching
 protected bool Equals(Fruit other)
 {
     return string.Equals(_description, other._description);
 }