I have loaded a txt comma delimited into multiple lists. For example
static public void File()
{
var order_no = new List<String>();
var quantity = new List<String>();
order_no.Add(fields[0]);
quantity.Add(fields[1]);
}
Now what i am trying to is in a loop while the same order is found down the list and the quantity is null then update the quantity in the previous.
For example
order NO : 1 quantity: null
order NO : 5 quantity: 2
order no : 1 quantity: 1
what it should do is to update the quantity in the first value to 1.
How can i accomplish that?
Personally i would prefer a
Dictionary<String, String>instead since these pairs belong logically together(one quantity per order). But ok…You could group by order_no and select only one not-null value(if any):
If you don’t want the first not-null quantity but the highest one, change these lines: