public static char? FindMostOccuranceOfCharInString(string value)
{
char? maxOccuranceChar = null;
int maxOccuranceValue = 0;
if (string.IsNullOrWhiteSpace(value))
return null;
char[] arr = value.ToLower().Trim().ToCharArray();
Dictionary<char, int> _dic = new Dictionary<char, int>();
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] != ' ')
{
if (!_dic.ContainsKey(arr[i]))
{ _dic.Add(arr[i], 1);}
else
{ _dic[arr[i]]++;
}}}
foreach (KeyValuePair<char, int> item in _dic)
{
if (item.Value > maxOccuranceValue)
{
maxOccuranceChar = item.Key;
maxOccuranceValue = item.Value;
} }
return maxOccuranceChar;
}