Can anyone tell me how to best possible way to convert the following code to LINQ:
static int MyMethod(MyClass my, bool b)
{
int cnt = 0;
foreach(SomeClass cls in my.SomeMethod()
{
cnt = cnt + cls.length;
}
if(b == true)
{
foreach(MyClass aa in my.SomeOtherMethod())
{
cnt = cnt + MyMethod(aa, true); // recursive
}
}
return cnt;
}
Please see that I know that the code above works fine, but I need to write it in LINQ and compare.