开发者

How to convert string to hashtable in 1 go?

开发者 https://www.devze.com 2023-04-05 11:12 出处:网络
This is strictly a learning experience: I have a .CSV file that I\'m using to define my d开发者_如何学编程eployment environments. One of the variables has to be in a Hash Table format.

This is strictly a learning experience:

I have a .CSV file that I'm using to define my d开发者_如何学编程eployment environments. One of the variables has to be in a Hash Table format.

Can anyone come up with a clever way to put it all in one line? Right now I harvest them as a string from CSV, conver to array, convert array to hash table.

Simplified code:

Foreach($i in $DefaultCSV){...
$App_Fabric_Hosts_a = $i.App_Fabric_Hosts.split(",")} 


$App_Fabric_Hosts_h = @{}
foreach($r in $App_Fabric_Hosts_a){$App_Fabric_Hosts_h.add($r,"22233")}


This is the best I came up with:

$d=@{};foreach($r in $DefaultCSV[$arrayposition].app_fabric_hosts.split(",")){$d.add($r,"22233")}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号