0

System.String変数のインスタンスを削除するにはどうすればよいですか?

$ Servers = "server"、 "localhost"

ローカルホストを削除したいのですが、何かアイデアはありますか?

4

1 に答える 1

0

You can set to $null the Array entry (you must know the index):

$Servers.Set(1, $NULL)

If you need a return value of [string] not an [objtect[]]

[string]$Servers = $Servers[0] # need always knowing the indexs 

If the Array count > 2 you need to do:

$Servers = $servers | ? { $_ -ne "localhost" }

or in short way

$servers = $servers -ne "localhost"

Or you can cast to ArrayList:

[System.Collections.ArrayList]$servers = $servers
$servers.Remove("localhost")
于 2012-04-06T10:59:27.453 に答える