34
1
using System;
2
/*Write a program to:
3
--> Check if two given strings are anagrams of each other
4
5
6
*/
7
public class Program
8
{
9
public static void Main(string[] args)
10
{
11
string word1="Welcome";
12
string word2="WelcomeW";
13
14
char[] word1Array=word1.ToLower().ToCharArray();
15
char[] word2Array=word2.ToLower().ToCharArray();
16
Array.Sort(word1Array);
17
Array.Sort(word2Array);
18
String str1=new String(word1Array);
19
String str2=new String(word2Array);
20
21
Console.WriteLine("String1 :{0}",str1);
22
Console.WriteLine("String1 :{0}",str2);
23
24
if(str1.Equals(str2))
25
{
26
Console.WriteLine("YES THEY ARE ANAGRAMS");
27
}else
28
{Console.WriteLine("NO THEY ARE NOT ANAGRAMS");}
29
30
31
}
32
33
34
}
Cached Result
In Dispose
In Dispose
In Dispose