Hash table in PowerShell
2016-05-31 16:21
387 查看
hashtable is easy to create, access and manipulate.
we simply use
to create an empty hash table.
and use
to set the key and value pair.
refer to http://ss64.com/ps/syntax-hash-tables.html, it is very flexible to use hash table.
one thing I want to point out is that whenver we want to traverse the hashtable, what can we do ?
just like an Array in PowerShell, using ForEach can do it.
For hashtable, we can use like:
or
we simply use
$hashTable = @{}
to create an empty hash table.
and use
$hashTable.color = "Blue"
to set the key and value pair.
refer to http://ss64.com/ps/syntax-hash-tables.html, it is very flexible to use hash table.
one thing I want to point out is that whenver we want to traverse the hashtable, what can we do ?
just like an Array in PowerShell, using ForEach can do it.
For hashtable, we can use like:
foreach ($dog in $dogs.GetEnumerator()) { # do what you like }
or
$hashtable.GetEnumerator() | ForEach-Object { … }
相关文章推荐
- Linux Shell的常用命令
- linux脚本Shell之awk详解(二)
- Linux shell 实现一键绑定多个网卡
- Shell基础 学习
- shell 编写脚本批量ping ip
- shell中的括号与引号
- [Android] 为Android安装BusyBox —— 完整的bash shell
- shell 两数相减取正值
- Linux Shell产生16进制随机数
- 巧用vim+sed整理shell脚本文件
- shell脚本的调试(trap、tee、shell选项)
- free命令要点
- Linux下profile和bashrc四种的区别
- Shell安装
- ShellExecute API函数用法简析
- 一天一个shell命令 文本操作系列-comm命令用法
- Xshell的简单说明
- JAVA远程调shell脚本
- FTP上传下载shell脚本
- 基于sparksql调用shell脚本执行SQL