Skip to content

How to convert back to array

Sin Yee

Asked Apr 5, 2011, 6:59 AM EDT1 answer
Share
LinkedInX
hi...i finish my intersection now. I need to convert the output back to the array. I also need to arrange them in 
the original form.
Before the intersection:
1 2 
1 2 3
1 2 3 4
1 3
1 3 4
....

Now my output is like this:
2
1
2
1
3
2
1
3
4
1
3
1
3
4

i need to restore output in array and make them become like this:
my expected output that i want:
2 1
2 1 3
2 1 3 4
1 3
1 3 4
..
here is my coding:
C#
 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();

           }
What should i need to do...to make my output become like this...hope someone can help me.thanks ya...

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Karthikeyan Anbarasan
    0
    Hi, im not sure about ur requirement on how much values it shld take and prepare a semi matrix format... try using jagged arrays and it might be helpful to you...
    0