Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Refactor nested foreach into LINQ ( if-else )

$
0
0

Hello Everyone, I am having troubles on finding a way to refactor my nested foreach code into a Linq, mostly because it includes an IF-Else clause into it.

Below is a simplified version of my code. How do I include the IF..Else into a linq statement??

I appreciate your suggestions.

List<hierarchy> PredomHierarchy;
List<hierarchy> RecesesHierarchy;

foreach x in PredomHierarchy{
foreach y in RecesesHierarchy{	
	if(x.name = y.name)		
{			Dosomething(x.name, y.name);				}		
else		
{			DosomethingElse(x.name, y.name);
		}
}}


Viewing all articles
Browse latest Browse all 31927

Trending Articles