I have a method which compares two lists of strings. If the strings, and only the strings, from listA
appear in listB
, return true
. Else return false
.
internal bool DoIdsMatchThoseFromXml(List<string> Ids, List<string> XmlIds)
{
bool result = true;
if (Ids.Count == XmlIds.Count)
{
foreach (var hwId in Ids)
{
if(!XmlIds.Contains(hwId))
{
result = false;
break;
}
}
}
else
{
result = false;
}
return result;
}
My initial unit test is passing (no edge cases etc. yet), but I was wondering if there is a more compact, but still readable, way to do it.