Anagram
using System;
using System.Linq;
namespace Anagram
{
class Program
{
static void Main(string[] args)
{
string word1 = "INDIA";
string word2 = "DIAIIN";
char[] char1 = word1.ToLower().ToCharArray().Distinct().ToArray();
char[] char2 = word2.ToLower().ToCharArray().Distinct().ToArray();
Array.Sort(char1);
Array.Sort(char2);
string NewWord1 = new string(char1);
string NewWord2 = new string(char2);
if (NewWord1 == NewWord2)
{
Console.WriteLine("Yes! Words \"{0}\" and \"{1}\" are Anagrams", word1, word2);
}
else
{
Console.WriteLine("No! Words \"{0}\" and \"{1}\" are not Anagrams", word1, word2);
}
Console.ReadLine();
}
}
}