这里是代码片段,我想在条件满足时退出函数。我怎样才能做到这一点?
bool MyNestedFunction()
{
Parallel.Foreach (ListofStrings_A, OuterString =>//loopA
{
Parallel.Foreach (ListofStrings_B, InnerString //loopB
{
string FirstTemperedString = Temperedstring.Substring(0,Temperedstring.LastIndexOf(" "));
string LastTemperedString = Temperedstring.Substring(Temperedstring.IndexOf(" "));
string FirstOuterString = OuterString.Substring(0, OuterString.LastIndexOf(" "));
string LastOuterString = OuterString.Substring( OuterString.IndexOf(" "));
if (FirstTemperedString.Equals(FirstOuterString) || LastTemperedString.Equals(LastOuterString))
{
return true; // I want to return from the function (MyNestedFunction)here
// What will be the alternate code here
}
});
})
return false;
}
return true 的替代语句将退出此函数?