I want to compare 2 string arrays in the fastest way.
I got something like below.
Will that be the right way to do. Or is there a better way to do
bool matching=false;
//say templateArr is the template array and dataArr as array to be compared
string[] templateArr = {"Dictionary_type","Translation_EN" };
string[] dataArr = { "Dictionary_type", "Translation_EN" };
if (templateArr.Union(dataArr).Distinct().Count() == templateArr.Count())
matching = true;
To test for collection equality, you can use
Enumerable.SequenceEqualsas follows.If you want to test for collection equivalence (order of elements does not matter), then you can use set-equality as follows.
Both cases are implemented in linear time, as per the MSDN documentation.