示例#1
0
        public static void Main(string[] args)
        {
            var tokens  = Console.ReadLine().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            var name    = $"{tokens[0]} {tokens[1]}";
            var address = tokens[2];
            var town    = tokens[3];

            var tuple1 = new Threeuple <string, string, string>(name, address, town);

            tokens = Console.ReadLine().Split();
            name   = tokens[0];
            var litersOBeer = int.Parse(tokens[1]);

            var condition = tokens[2].ToLower() == "drunk";

            var tuple2 = new Threeuple <string, int, bool>(name, litersOBeer, condition);

            tokens = Console.ReadLine().Split();
            name   = tokens[0];
            var accountBalance = double.Parse(tokens[1]);
            var bankName       = tokens[2];

            var tuple3 = new Threeuple <string, double, string>(name, accountBalance, bankName);

            Console.WriteLine(tuple1);
            Console.WriteLine(tuple2);
            Console.WriteLine(tuple3);
        }
示例#2
0
        static void Main()
        {
            var fullNameAndAddress = Console.ReadLine().Split();
            var nameAndBeer        = Console.ReadLine().Split();
            var intAndDouble       = Console.ReadLine().Split();

            var tupleFullNameAndAddress = new Threeuple <string, string, string>(fullNameAndAddress[0] + " " + fullNameAndAddress[1], fullNameAndAddress[2], fullNameAndAddress[3]);
            var tupleNameAndBeer        = new Threeuple <string, int, bool>(nameAndBeer[0], int.Parse(nameAndBeer[1]), nameAndBeer[2] == "drunk" ? true : false);
            var tupleIntAndDouble       = new Threeuple <string, double, string>(intAndDouble[0], double.Parse(intAndDouble[1]), intAndDouble[2]);

            Console.WriteLine(tupleFullNameAndAddress);
            Console.WriteLine(tupleNameAndBeer);
            Console.WriteLine(tupleIntAndDouble);
        }
示例#3
0
        public static void Main(string[] args)
        {
            var tokens = Console.ReadLine().Split();

            tokens[0] = $"{tokens[0]} {tokens[1]}";
            var firstTuple = new Threeuple <string, string, string>(tokens[0], tokens[2], tokens[3]);

            PrintTuple(firstTuple);

            tokens = Console.ReadLine().Split();
            bool isDrunk     = tokens[2] == "drunk";
            var  secondTuple = new Threeuple <string, int, bool>(tokens[0], int.Parse(tokens[1]), isDrunk);

            PrintTuple(secondTuple);

            tokens = Console.ReadLine().Split();
            var thirdTuple = new Threeuple <string, double, string>(tokens[0], double.Parse(tokens[1]), tokens[2]);

            PrintTuple(thirdTuple);
        }
示例#4
0
 private static void PrintTuple <T1, T2, T3>(Threeuple <T1, T2, T3> threeuple)
 {
     Console.WriteLine($"{threeuple.Item1} -> {threeuple.Item2} -> {threeuple.Item3}");
 }