如何在Powershell中比较关联数组? [英] How to compare Associative arrays in Powershell?

查看:56
本文介绍了如何在Powershell中比较关联数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个关联数组

$a = @{"k1"="v1"; "k2"=@{"k21"="v21"}} 

$b = @{"k1"="v1"; "k2"=@{"k21"="v21"}} 

我想知道有没有什么好方法可以在不编写自己的函数的情况下进行比较?

I was wondering is there any good way do the comparison without writing my own function?

推荐答案

除了编写用于比较每个键的值的函数(如果该值不是原始对象的值,则可能是递归的)之外,我没有其他方法可知.但是,PowerShell中的关联数组只是.NET类型(System.Collections.Hashtable).您可能想要通过向问题中添加 .NET 标记来向更广泛的.NET受众开放此问题.

There isn't a way that I know of except writing a function to compare each key's value (potentially recursive if the value is something other than a primitive object). However, associate arrays in PowerShell are just .NET types (System.Collections.Hashtable). You might want to open this question up to the broader .NET audience by adding the .NET tag to your question.

这篇关于如何在Powershell中比较关联数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆