Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 176760

Creating a table and rows

$
0
0

All,

  So, I'm tinkering around with creating an array and then adding rows and I'm trying to understand this behavior.

 

For example:

 

If I do this:

 

$table = @()

$row = "" | Select Name,Value

$row.Name = "test"

$row.Value = "Prod"

 

$table += $row

 

$table


Name                                                        Value
----                                                        -----
test                                                        Prod

 

 

It works.  Then if i try to add another row with out initializing a new $row array it overwrites the original why?

 

$row.Name = "test2"

$row.Value = "NonProd"

 

$table += $row

 

$table

 

Name                                                        Value
----                                                        -----
test2                                                       NonProd
test2                                                       NonProd

 

But if I do this it adds to bottom.  Why does it behave this way where I have to reinitialize the row every time?

$row = "" | Select Name,Value

$row.Name = "test"

$row.Value = "Prod"

$table += $row

Name                                                        Value
----                                                        -----
test2                                                       NonProd
test2                                                       NonProd
test                                                        Prod


Viewing all articles
Browse latest Browse all 176760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>