"c# code to check anagram" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "c# code to check anagram" answered properly. Developers are finding an appropriate answer about c# code to check anagram related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like c# code to check anagram. Enter your desired code related query in the search bar and get every piece of information about C# code related question on c# code to check anagram.
c# code to check anagram

string a = "abcd";
string b = "bcda"; // bad daa a1b2c3 abc123
string aa = String.Concat(a.OrderBy(c => c));
string bb = String.Concat(b.OrderBy(c => c));
if (aa == bb)
{
Console.WriteLine("YES");
}
else
{
Console.WriteLine("NO");
}
Source: stackoverflow.com
c# code to check anagram

public bool IsAnagram(string s1,string s2)
{
if (s1.Length != s2.Length)
return false;
var s1Array = s1.ToLower().ToCharArray();
var s2Array = s2.ToLower().ToCharArray();
Array.Sort(s1Array);
Array.Sort(s2Array);
s1 = new string(s1Array);
s2 = new string(s2Array);
return s1 == s2;
}
Source: stackoverflow.com
c# code to check anagram

if (String.Concat(a.OrderBy(c => c)).Equals(String.Concat(b.OrderBy(c => c))) ...
Source: stackoverflow.com
c# code to check anagram

void Test()
{
string a = "abccabccabccabccabccabccabccabccabccabccabccabccabccabccabccabcc";
string b = "bcacbcacbcacbcacbcacbcacbcacbcacbcacbcacbcacbcacbcacbcacbcacbcac";
IsAnagramSimple(a, b);
IsAnagramFast(a, b);
}
private bool IsAnagramSimple(string a, string b)
{
return a.OrderBy(c => c).SequenceEqual(b.OrderBy(c => c));
}
private bool IsAnagramFast(string a, string b)
{
if (a.Length != b.Length)
{
return false;
}
var aFrequency = CalculateFrequency(a);
var bFrequency = CalculateFrequency(b);
foreach (var key in aFrequency.Keys)
{
if (!bFrequency.ContainsKey(key)) return false;
if (aFrequency[key] != bFrequency[key]) return false;
}
return true;
}
private Dictionary<char, int> CalculateFrequency(string input)
{
var frequency = new Dictionary<char, int>();
foreach (var c in input)
{
if (!frequency.ContainsKey(c))
{
frequency.Add(c, 0);
}
++frequency[c];
}
return frequency;
}
Source: stackoverflow.com
All those coders who are working on the C# based application and are stuck on c# code to check anagram can get a collection of related answers to their query. Programmers need to enter their query on c# code to check anagram related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c# code to check anagram for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of c# code to check anagram while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "c# code to check anagram". Visit this developer's friendly online web community, CodeProZone, and get your queries like c# code to check anagram resolved professionally and stay updated to the latest C# updates.