Wednesday, June 15, 2011

Find the most repeated wordin the string.


public static void findmaximumcharinstring()
string str11 = "my name is ayyappan as as i i am working as an software engineer in hexaware i had two year experianced in microsoft platform";
string str1 = "bayyappppan";
string[] name = new string[str1.Length];
string[] stringval = new string[100];
string[] word = str11.Split(' ');
int cout=0;
foreach (var w in word)Array.FindAll(stringval, val => val != null).ToArray();
 var local =
(from p in stringvalgroup p by p into gselect new { charec = g.Key, chareccount = g.Count() }).OrderByDescending(x => x.chareccount);
int t=0;
foreach (var l in local)
if (t != 0)
if (l.chareccount != t)break;
Console.WriteLine("Maximum repeted string is:{0} and the count is : {1}",
 l.charec, l.chareccount);
}
}