January 2012
Intermediate to advanced
396 pages
8h 16m
English
Follow the given steps:
Ganagram (short form for generic anagram). This is a showcase of SortedList<TKey,TValue>, solving a real problem.Program.cs file:public static bool IsAnagram<T>(IEnumerable<T> first, IEnumerable<T> second)
{
SortedList<T, int> val = new SortedList<<T, int>();
foreach (T element in first)
{
if (!val.ContainsKey(element))
val.Add(element, 1);
else
val[element]++;
}
foreach (T element in second)
{
if (val.ContainsKey(element))
val[element]--;
else
return false;
}
foreach (T element in val.Keys)
{
if (val[element] != 0)
return false;
}
return true;
}Main() method of the console application as follows: ...Read now
Unlock full access