Exemplo n.º 1
0
        static List <object> SortObjectByCount(List <object> LetterAndCounts)
        {
            List <object> sortedByCount =
                (from LetterAndCount in LetterAndCounts
                 orderby LetterAndCount.GetType().GetProperty("Count").GetValue(LetterAndCount) descending
                 select LetterAndCount).ToList();

            return(sortedByCount);
        }
Exemplo n.º 2
0
        static List <object> SortObjectByLetter(List <object> LetterAndCounts)
        {
            List <object> sortedByLetter =
                (from LetterAndCount in LetterAndCounts
                 orderby LetterAndCount.GetType().GetProperty("Letter").GetValue(LetterAndCount).ToString().ToLower()
                 select LetterAndCount).ToList();

            return(sortedByLetter);
        }
Exemplo n.º 3
0
        static void DisplayLetterAndCounts(List <object> LetterAndCounts)
        {
            foreach (object LetterAndCount in LetterAndCounts)
            {
                char letter      = (char)LetterAndCount.GetType().GetProperty("Letter").GetValue(LetterAndCount);
                int  letterCount = (int)LetterAndCount.GetType().GetProperty("Count").GetValue(LetterAndCount);

                Console.WriteLine($"{ letter }: { letterCount }");
            }
        }