I am working in C#. I have a class model:
public class CustomerViewModel
{
public string Name;
public string[][] values;
public bool[] flag;
}
I wish to extract values[x][0] from all rows of values where flag==false, using LINQ
Something like this should do it:
var result = custVm.flag.Select((f, i) => new { f, val = custVm.values[i][0] })
.Where(i => !i.f)
.Select(i => i.val);
For every entry in the flag array, you're mapping the value from the first column of the values array to a new anonyomous object, containing the flag and the value.
You're then filtering this list of anonymous objects by flag == false.
Then you're selecting just the 'value' parts of the anonymous objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With