|
| |||||||||
| Tags: hash table, powershell |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| 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
| ||||
| ||||
| 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
| |||
| |||
| 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
| ||||
| ||||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Powershell: declare hash table" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Link a Table to another Table to Drop Down In Main Table | himeshRES | Windows Software | 6 | 11-12-2010 02:01 PM |
| What is the Declare Construct in PHP? | Rob Dizzle | Software Development | 5 | 06-03-2010 03:51 AM |
| Creating a Hash Table in java | Sheenas | Software Development | 5 | 19-02-2010 07:24 PM |
| From Hash Table Remove an Unreferenced Element | Level8 | Software Development | 5 | 19-02-2010 05:39 PM |
| Calculating a hash table automatically in SQL | Elijah | Software Development | 4 | 03-04-2009 12:37 AM |