Example #1
0
        static void Main(string[] args)
        {
            Rectangle R = new Rectangle(10, 10);

            var result = R switch
            {
                Rectangle(0, 0) => "The value of length and breadth is zero.",
                Rectangle(10, 5) => "The value of length is 10, breadth is 5.",
                Rectangle(10, 10) => "The value of length and breadth is same – this represents a square.",
                _ => "Meeeh."
            };

            Console.WriteLine(result);

            Voyager voyager = new Voyager()
            {
                CountryOrigin = "Nigeria",
                Mileage       = 45,
                Oriki         = "Ologo 5G",
                Destination   = "Canada"
            };

            bool grantEntry = ShouldAllowEntry(voyager);

            Console.WriteLine("{0}, you have been {1} visa to {2}", voyager.Oriki, grantEntry ? "granted" : "denied", voyager.Destination);

            Console.WriteLine(AnnounceTeams("Getafe", "Ajax"));
            Console.WriteLine(AnnounceTeams("Liverpool", "AFC Bournemouth"));
        }
Example #2
0
 public static bool ShouldAllowEntry(Voyager hobo) =>
 hobo switch
 {
     { CountryOrigin : "Nigeria", Destination : "Nigeria" } => true,