Explanation
string str = "thisistestingfileforthetrainees";
var x = from a in str
group a by a into g
select g;
foreach(var item in x)
{
Console.WriteLine(item.Key + "\t" + item.Count());
}
This program used to display character and frequency of character from given string.Explanation
int[] num = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 6, 2 };
var x = from a in num
group a by a into g
select g;
foreach (var item in x)
{
Console.WriteLine(item.Key + "\t" + item.Count());
}
This program used to display number and frequency of number from given array. Explanation
int[] num = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 6, 2 };
var x = from a in num
group a by a into g
select g;
foreach (var item in x)
{
Console.WriteLine(item.Key + "\t" + item.Sum()+"\t"+item.Count());
}
This program used to display number, multiplication of number with number frequency and frequency of number from given array.Note
Group clause used to create a group of values with key. Key contain unique data and can perform operation on value as getting count operation or getting sum operation etc.
