TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sin Yee
NA
145
74.8k
How to split the line by line
Apr 1 2011 6:06 PM
hi..i am doing split now. But i face some problem.
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
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);
Reply
Answers (
1
)
Getting a specific nummber from an Array based on variable?
catch blocks that don't catch anything