Reputation: 181
I have a structure:
public struct rawData {
public string recType;
public string ncmCode;
public string depotNo;
public string accNo;
public string kVK;
public string callPut;
public string quanSetUnset;
public string abbNameOTC;
}
public List<rawData> myData = new List<rawData>();
rawData tempRawData = new rawData();
into which I import data to from csv.
My question is, depeding on accNo
, how can I copy just specific "rows" into a new list of the same structure.
I can loop through the list
if (account == "xxxxx") {
for (int i = 0; i < myData.Count; i++) {
if (myData[i].accNo == account) {
myData.CopyTo(acc85RawD, i);
}
}
}
Im using the copyto but its wrong as that copies to a array, the index i, i need it to copy all elements of index i to a new list....
any help? thanks
Upvotes: 0
Views: 128
Reputation: 613
The projection in LINQ might help..
myData.Where(i=>i.accNo==account).Select(i=>new rawData{recType=i.recType,..});
Upvotes: 3