Пример #1
0
        public string ShowType(Garage <Vehicle> gar)
        {
            string result = "";
            var    vlist  = gar.OfType <Vehicle>().Where(x => x != null).GroupBy(x => x.GetType().Name).Select(g => new
            {
                type  = g.Key,
                count = g.Count()
            });

            foreach (var v in vlist)
            {
                result += v.type + ": " + v.count + "\n";
            }
            return(result);
        }
Пример #2
0
        public void ShowListType(Garage <Vehicle> gar, string typ)
        {
            var vlist = gar.OfType <Vehicle>().Where(x => x.GetType().Name.Equals(typ, StringComparison.InvariantCultureIgnoreCase));

            if (vlist.Count() == 0)
            {
                Console.WriteLine("Not found any vehicle from the type {0}", typ);
            }
            else
            {
                foreach (var v in vlist)
                {
                    Console.WriteLine(v);
                }
            }
        }