I'm trying to convert String datatype to Object[].
Required Format and Required Datatype:
$demilimitedIds = {/subscriptions/XXX},{/subscriptions/XXX}
echo $demilimitedIds.GetType().Name ##datatype of $demilimitedIds is Object[]
My Code:
[System.Collections.Generic.List[System.String]]$IDList = @()
$IDList.Add("/subscriptions/XXX")
$IDList.Add("/subscriptions/XXX")
$Alist = '{{{0}}}' -f ($IDList -join '},{')
echo "%%%%%%%%%%%%%%%"
echo $Alist.GetType().Name //o/p format of $Alist is String
echo "%%%%%%%%%%%%%%%"
I'm trying to convert the $IDList into required format similar to $demilimitedIds and of same Object[] datatype.
How to convert datatype of $Alist from String to Object[] ?
$Alistto an object or just create an object from values instead of the way you're creating$IDlist?$IDListcan already be used as Object[] with a parameter. If you really need to use$Alistthen$Alist = @($IDList)will give you Object[] with the contents of$IDList$Alist = @($Alist)