c# - How to find an Index of a string in a list -
so trying retrieve index of first item, in list, begins "whatever", not sure how this.
my attempt (lol):
list<string> txtlines = new list<string>(); //fill list<string> lines txt file. foreach(string str in file.readalllines(filename)) { txtlines.add(str); } //insert line want add last under tag 'item1'. int index = 1; index = txtlines.indexof(npcid);
yea know isn't anything, , wrong because seems looking item equal npcid rather line begins it.
if want "startswith" can use findindex
int index = txtlines.findindex(x => x.startswith("whatever"));
Comments
Post a Comment