I have data to looks has the following format. I'd like to create a new 2 column array for each "ran" with the respective ran name after the :.
Ran: Efg (space between : and E)
1 50 (tab delimited)
2 52 (tab delimited)
3 54 (tab delimited)
Ran: pg2 (space between : and E)
1 40 (tab delimited)
2 60 (tab delimited)
3 80 (tab delimited)
Ran: 2 (space between : and E)
1 14 (tab delimited)
2 15 (tab delimited)
3 16 (tab delimited)
So far, I've a problem with using the following because it gives me an infinite loop, but I'm not sure how else to access the string resulttext from a previous
public void openDVHToolStripMenuItem_Click (object sender, EventArgs e){....}
public static string resulttext
{
get { return resulttext; }
}
Secondly, I've got the following so far to separate the name of the 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 to be able to call each array later and do some basic math on the values from both columns of numbers.
Any suggestions?
This:
public static string resulttext
{
get { return resulttext; }
}
gives you an “infinite loop” because it is recursive; return resulttext
calls public static string resulttext
. Do this:
public static string ResultText { get; private set; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.