zoukankan      html  css  js  c++  java
  • Hash table in PowerShell

    hashtable is easy to create, access and manipulate.

    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 { … } 
    

      

  • 相关阅读:
    HTTP协议
    JavaScript学习(一)
    Cookie&Session
    注解初学
    反射初学
    XML
    Web概念
    Response对象
    Servlet
    LeetCode Notes_#617 Merge Two Binary Trees
  • 原文地址:https://www.cnblogs.com/wushuaiyi/p/5546281.html
Copyright © 2011-2022 走看看