我正在構建自定義PSObject數組,但我注意到沒有明顯原因正在插入大量額外空間。例如:自定義PSObject中的額外空間
PS> $user = @()
PS> $user += New-Object PSObject -Property @{"Name" = "John Smith"}
PS> $user += New-Object PSObject -Property @{"Age" = "18"}
PS> $user += New-Object PSObject -Property @{"City of birth" = "New York"}
PS> $user += New-Object PSObject -Property @{"Pet" = "none"}
PS> "[$($user.Name)]"
[John Smith ]
PS> "[$($user.Pet)]"
[ none]
好像我添加的更多鍵/值對,將更多空間添加到這些值。任何想法,爲什麼這是?
你正在建立一個數組......不應該通過'「[$數組中的元素,選擇NoteProperty Name? –