Given an ItemID number (not the same as the Item[index_pos] in allItems List, I am able to retrieve an Item using:
QM_Items theItem = qmload.allItems.Where (x => x.iID == _iID).FirstOrDefault ();
Now I’d like to figure out how to get the index of allItems where the itemID (unique) is positioned. Per this
http://stackoverflow.com/questions/2471588/how-to-get-index-using-linq
I was trying (pseudo):
myCars.Select((v, i) => new {car = v, index = i}).First(myCondition).index;
but unsure how to translate (myCondition) into my Unity project setup. Tried this:
int ItemINDEX = qmload.allItems.Select ((v,i) =>
new {QM_Items=v, index = i}).FirstOrDefault (v => v.QM_Items.iID => _iID).index;
but compiler doesn’t like it or various forms I’ve attempted. Could someone more familiar with LINQ tell me how to write that?