public static char MaximumOccurringCharacter(this string input)
        {
           
SortedDictionary<char, int> charDict = new SortedDictionary<char, int
>();
           
int
length = input.Length;

            for (int i = 0; i < length; i++)
            {
               
if
(charDict.ContainsKey(input[i]))
                {
                    charDict[input[i]]++;
                }
               
else
               
{
                    charDict.Add(input[i], 1);
                }
            }

            var max = charDict.Values.Max();
           
var
relevantKeys = charDict.Where(pair => max.Equals(pair.Value))
                .Select(pair => pair.Key).First();
           
return
relevantKeys;

        }

Test Case

Console.WriteLine("Max occur char in string test is : " + "test".MaximumOccurringCharacter());

Console.WriteLine("Max occur char in string maximum is : " + "maximum".MaximumOccurringCharacter());

Console.WriteLine("Max occur char in string MaximumOccurringCharacter is : " + "MaximumOccurringCharacter".MaximumOccurringCharacter());

Output

Max occur char in string test is : t
Max occur char in string maximum is : m
Max occur char in string MaximumOccurringCharacter is : r