Results 1 to 4 of 4

Thread: Powershell: declare hash table

  1. #1
    Join Date
    May 2008
    Posts
    979

    Powershell: declare hash table

    I am learning PowerShell. I would like to know how to declare the hash table in PowerShell? Also what is the actual usage of hash table? What are are the benefits of it?

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Powershell: declare hash table

    PowerShell Hash Table allows you to store key-value pairs. It is an array that allows you to store data in a “key-value” pair association. The “key” and “value” entries can be any data type and length. The elements must be quoted if they contain a space.

    Just like an array, a hash table is declared with "@" symbol. The hash “key-value” pairs are enclosed in curly brackets {} and its elements are separated by the semi-colon.

    To create a hash table:

    $EmpName = @{"Alap"; "Sanjay"; "Arpita"}

    Source: powershellpro

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Powershell: declare hash table

    A hash table is simply a collection of name-value pairs, very much like the FileSystemObject’s Dictionary object. For example, suppose you have a collection of Indian states and their capitals. Each state has one and only one capital and a given city can be the capital of only one state. So a hash table goes something like this:

    $states = @{"Maharashtra" = "Mumbai"; "Rajasthan" = "Jaipur"; "Andhra Pradesh" = "Hyderabad"}

    So the syntax for creating a hash table involves using an at the rate sign (@) followed by a pair of curly braces.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Powershell: declare hash table

    A hash table consists of two parts: an array and a mapping function, known as a hash function. The hash function is a mapping from the input space to the integer space that defines the indices of the array. In other words, the hash function provides a way for assigning numbers to the input data such that the data can then be stored at the array index corresponding to the assigned number. A hash function doesn't guarantee that every input will map to a different output. There is always the chance that two inputs will hash to the same output. This indicates that both elements should be inserted at the same place in the array, and this is impossible.

    Source: sparknotes

Similar Threads

  1. Link a Table to another Table to Drop Down In Main Table
    By himeshRES in forum Windows Software
    Replies: 6
    Last Post: 11-12-2010, 02:01 PM
  2. What is the Declare Construct in PHP?
    By Rob Dizzle in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 03:51 AM
  3. Creating a Hash Table in java
    By Sheenas in forum Software Development
    Replies: 5
    Last Post: 19-02-2010, 07:24 PM
  4. From Hash Table Remove an Unreferenced Element
    By Level8 in forum Software Development
    Replies: 5
    Last Post: 19-02-2010, 05:39 PM
  5. Calculating a hash table automatically in SQL
    By Elijah in forum Software Development
    Replies: 4
    Last Post: 02-04-2009, 11:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,683,557.28625 seconds with 16 queries