Exemplo n.º 1
0
        private async Task <bool> GenderCountByAgeAssending()
        {
            var dict = await Task.Run(() => dataSource.All("Age"));

            var text = string.Empty;

            if (dict != null)
            {
                foreach (var element in dict)
                {
                    text = new StringBuilder().
                           AppendFormat(
                        "{0}Age: {1} Female: {2} Male: {3} Unknown: {4}\n",
                        text,
                        element.Key,
                        element.Value.Count(x => x.Gender == Gender.Female),
                        element.Value.Count(x => x.Gender == Gender.Male),
                        element.Value.Count(x => x.Gender == Gender.Unknown)
                        ).ToString();
                }
            }

            output.WriteLine("The number of genders per Age, displayed from youngest to oldest | Found = {0}\n{1}\n",
                             dict != null ? dict.Count : 0,
                             dict != null ? text : "Not Found!"
                             );

            return(true);
        }