hi..i finish my intersection. Now i need to convert the output in the array.
Now, my output is in hashset. i need to convert back to array.
my output now is like this
2
1
2
1
3
2
1
3
4
And now, i wan them to become like this
2 1
2 1 3
2 1 3 4
....
how to make my output become like this?? hope someone can help me..

for (int i = 0; i < myArray1.Count; i++)
           {
               foreach (string t in myArray1[i].ToString().Split(' '))
               {
                   //ItemKey.AppendText(t);
                   hs3.Add(t);
               }
               var clone = new HashSet<string>(hs2);
               hs2.IntersectWith(hs3);
               foreach (string y in hs2)
               {

                   ItemKey.AppendText(y);
               }

               hs2 = clone;
               hs3.Clear();  
           }

How can you tell how many items should be grouped together?

oh...because my previous data is like this
1 2
1 2 3
1 2 3 4
......

Yes, but what if it wasn't. How would your program know how to group them together without the prior knowledge?

So, what should i do..?

this is my coding..but my coding just can display out the first output 2 1 after that will give me the error..."Index was outside bound of array"...what should i do..?

string [] Array = new string[myArray1.Count];
           String[] strarry;
           for (int i = 0; i < myArray1.Count; i++)
           {   
               foreach (string t in myArray1[i].ToString().Split(' '))
               {
                   //ItemKey.AppendText(t);
                   hs3.Add(t);
               }

               var clone = new HashSet<string>(hs2);
              
               hs2.IntersectWith(hs3);

               strarry = hs2.ToArray();
            
              string[] myArray2 = new string[myArray1.Count];
              int[] lens = new int[myArray1.Count];
              int index = 0;
              foreach (string y in myArray1)
              {
                  lens[index] = y.Replace(" ", "").Length;
              }
              index = 0;
              int index2 = 0;
              string[] temp = new string[lens[0]];

              foreach (string q in strarry)
              {
                  if (index2 < lens[index])
                  {
                      temp[index2] = q.ToString();
                      index2++;
                  }
                  else
                  {
                      myArray2[index] = String.Join(" ", temp);
                      index++;
                      temp = new string[lens[index]];
                      temp[0] = q.ToString();
                      index2 = 1;
                  }
              }
              myArray2[index] = String.Join(" ", temp);
              ItemKey.AppendText(String.Join("\r\n", myArray2));
              
              hs2 = clone;
              hs3.Clear(); 
           }

hope someone please help me....thanks you so much...

because my output now is like this 21213213413....in string array.....
i need to change back to previous style with new output
previous style:

1 2
1 2 3
1 2 3 4
1 3
1 3 4
....
Now, i want is like this
2 1
2 1 3
2 1 3 4
1 3
1 3 4
....

because my output now is like this 21213213413....in string array.....
i need to change back to previous style with new output
previous style:

1 2
1 2 3
1 2 3 4
1 3
1 3 4
....
Now, i want is like this
2 1
2 1 3
2 1 3 4
1 3
1 3 4
....

can someone help me check the coding that i post avove

because my output now is like this 21213213413....in string array.....
i need to change back to previous style with new output
previous style:

1 2
1 2 3
1 2 3 4
1 3
1 3 4
....
Now, i want is like this
2 1
2 1 3
2 1 3 4
1 3
1 3 4
....

can someone help me check the coding that i posted above post

but my coding just can display out the first output 2 1 after that will give me the error..."Index was outside bound of array"...what should i do..?

Ever heard of a thing called "debugger"?
The one in VS is a charm to work with, believe me.

"temp[0] = q.ToString();"
this line give me error...
still donn't know how to fix..

Debug some more!
My car gives me errors all the time, you can fix them right now, isn't it? 'cause you know what the errors of my car are, right?

oo....it can display already but my output very weird..
Seem like this
2 1


2 1
3


2 1
3 4

.......
the output between will have many spaces
So, what i need to do to change it like
2 1
2 1 3
2 1 3 4
.....and so on....

Bye :) I have a virus in my car, have to handle that with high priority!!!

????okk.....

anyone can help me...?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.