# Anagram Detection

Anagram Detection programming exercise

An anagram is the result of rearranging the letters of a word to produce a new word.

The “mystics and alchemists” society of SQL City are very mystified. They have discovered the anagrams! They offer to turn some of your lead into gold (or was is the opposite ?…) if you help them with a function.

Write a function that checks if two strings are anagrams of each other.

```Example:
"taste" => "state"
"car" => "arc"

Scroll down for the solution of this coding problem.```
```    public static bool IsAnagram(string test, string original)
{
//lets make two words lowercase for easier checking
//by using the ToLower() function on the strings
test = test.ToLower();
original = original.ToLower();

//if the both words are not the same length
if (test.Length != original.Length) return false;

//we will use ToArray() function on the both words
//to make them into char arrays
char[] a = test.ToArray();
char[] b = original.ToArray();

//so we can sort them using Array.Sort() function
Array.Sort(a);
Array.Sort(b);

//Now we will manually check if the two array
//are equal by going through each character and
//comparing them. If we find even one different
//character its we return false
for (int i = 0; i < a.Length; i++)
{
if (a[i] != b[i]) return false;
}

//and if every single character is the same
//we return true.
return true;
}```