c# - Save sections of text data to arrays -
i have data looks has following format. i'd create new 2 column array each "ran" respective ran name after :.
ran: efg (space between : , e) 1 50 (tab delimited) 2 52 (tab delimited) 3 54 (tab delimited) ran: pg2 (space between : , e) 1 40 (tab delimited) 2 60 (tab delimited) 3 80 (tab delimited) ran: 2 (space between : , e) 1 14 (tab delimited) 2 15 (tab delimited) 3 16 (tab delimited) so far, i've problem using following because gives me infinite loop, i'm not sure how else access string resulttext previous
public void opendvhtoolstripmenuitem_click (object sender, eventargs e){....} public static string resulttext { { return resulttext; } } secondly, i've got following far separate name of array-to-be.
private void button1_click(object sender, eventargs e) { dictionary<string, list<string>> darray = new dictionary<string, list<string>>(); using (stringreader reader = new stringreader(resulttext)) { string line; string ran = "ran:"; string region = ""; while (null != (line = reader.readline())) { if (line.contains(ran)) { string[] splitheader = line.split(":".tochararray()); region = splitheader[1].trim(); } else { if (!line.contains(ran)) { list<string> dlist = new list<string>(); darray.add(region, dlist); } } } foreach (var item in darray) { richtextbox2.appendtext(item + environment.newline); } } } i have able call each array later , basic math on values both columns of numbers.
any suggestions?
this:
public static string resulttext { { return resulttext; } } gives “infinite loop” because recursive; return resulttext calls public static string resulttext. this:
public static string resulttext { get; private set; }
Comments
Post a Comment