i have a problem to separate last number from arrayList.
my exist arrayList are shown below:
1 2
1 3
1 2
2 3
1 2 3
1 3
2 3
1 2 3
may i know how to separate the last number, and store it into 2 araryList?
my expected output is
1st arraylist :
1
1
1
2
1 2
1
2
1 2
my second arrayList is:
2
3
2
3
3
3
3
3
hope someone can help me.
Loading
VulpesPosted Apr 8, 2011, 6:41 PM
If it does, I'd try instead:
foreach (string s in richTextBox11.Lines)
{
int len = s.Length;
if (len == 0) continue;
al2.Add(s.Substring(0, len - 2));
al3.Add(s.Substring(len - 1));
}
Sam HobbsPosted Apr 9, 2011, 4:45 PM
Sam HobbsPosted Apr 9, 2011, 4:16 PM
Suthish NairPosted Apr 9, 2011, 2:15 AM
y sPosted Apr 8, 2011, 6:56 PM
y sPosted Apr 8, 2011, 6:33 PM
ArrayList al2 = new ArrayList();
ArrayList al3 = new ArrayList();
foreach (string s in richTextBox11.Lines)
{
int len = s.Length;
al2.Add(s.Substring(0, len - 2));
al3.Add(s.Substring(len - 1));
}
richTextBox15.Clear();
foreach (string s in al2)
{
richTextBox15.AppendText(s);
}
richTextBox16.Clear();
foreach (string s in al3)
{richTextBox16.AppendText(s);
}
M i make some mistake?
VulpesPosted Apr 8, 2011, 6:09 PM