For example'
i got data in String array
"1 2"
"1 2 3"
"2 3"
.......
But, after i split the data
All will become like this
1
2
1
2
3
2
3
but this is not i want..
the expected output that i want is like this
Output 1
1
2
output2
1
2
3
output3
2
3
and so on......this is my coding. hope someone can help me to solve this problem
C#
List<KeyValuePair<String, int>> P = new List<KeyValuePair<String, int>>(itemS.ToList());
KeyitemS.Clear();
String[] SplitA;
String[] SplitB;
List<String> l = new List<String>();
foreach (KeyValuePair<String, int> pair in P)
{
KeyitemS.AppendText(pair.Key + ":" + pair.Value + "\r\n");
l.Add(pair.Key);
}
String ink ="";
List <String> U =new List<String>();
foreach (String inter in l)
{
// MessageBox.Show(inter);
SplitA = inter.Split(' ');
SplitB = new String[SplitA.Length];
for (int i = 0; i < SplitA.Length; i++)
{
SplitB[i] = SplitA[i];
U.Add(SplitB[i]);
}
HashSet<string> hset1 = new HashSet<string>(v);
HashSet<string> hset2 = new HashSet<string>(U);
hset1.IntersectWith(hset2);
foreach (string inter1 in hset1)
{
ink += inter1;
}
MessageBox.Show(ink);
Suthish NairRank #93 · 22.6K pointsPosted Apr 2, 2011, 7:04 AM EDT
string[] s1 = { "1 2" };
string[] s2 = { "1 2 3" };
string[] s3 = { "2 3" };
List<string[]> s = new List<string[]>();
s.Add(s1);
s.Add(s2);
s.Add(s3);
for (int i = 0; i < s.Count; i++)
{
Console.WriteLine("Output " + (i + 1));
foreach (string item in s[i][0].ToString().Split(' '))
{
Console.WriteLine(item.Trim());
}
}
Console.ReadLine();