How can I improve the performance if this Code snippet.
bool OrSetFinalResult =true;
string OrSet = "(1&1)|0";
string[] AndSets = OrSet.Split('&');
foreach (string AndSet in AndSets)
{
if (AndSet == "0")
{
// A single "false" statement makes the entire And statement FALSE
OrSetFinalResult = false;
break;
}
}
Is there any way to remove the ForEach loop with any of the LINQ expressions ?
Sounds like:
No need for LINQ at all. It’ll still loop internally of course, but it’s still a lot simpler.
EDIT: As noted in comments, you could also use: