You may have some arrays like this:

Then you may want to combine them together:

But unfortunately it’s not simple like this…

You will get:

Suppose to be 2, right? Why it’s 6… Let’s identify…

But what I want it to be is $School contains $year1 and $year2, and $year1 contains its own people, the same as $year2.

Here is the solution…

Let’s double check the new array:

Whooya~.

  • What if we add a new year?
  • What if we add a new year with more or less members?
  • What if we remove a year?

The reason why we do this is due to the limitation in PowerShell Array operation. It would be much easier if we use ArrayList. 🙂

 

Enjoy.

River