- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between Dictionary and HashTable in PowerShell?
PowerShell programmers generally prefer the Hashtable over the Dictionary although there are some advantages of using Dictionary. See the difference below.
a. Hashtable is easy to declare while the Dictionary is a little complex compared to Hashtable. For example,
To create a hashtable,
$hash = @{ 'Country' = 'India' 'Code' = '91' }
To create a Dictionary,
$citydata = New-Object System.Collections.Generic.Dictionary"[String,Int]" $citydata.Add('India',91)
b. Hashtable is included in the namespace called Collections while Dictionary is included in the namespace called System.Collections.Generic namespace. Hashtable is non-generic so it can be a collection of different data types and Dictionary belongs to a generic class so it is a collection of specific data types.
c. Hashtable and Dictionary both have the BaseType is Object but their datatypes are different. Hashtable has a ‘Hashtable’ datatype and Dictionary has a Dictionary`2 datatype.
Hashtable:
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Hashtable System.Object
Dictionary:
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Dictionary`2 System.Object
- Related Articles
- Difference between Dictionary and Hashtable in C#
- Difference between HashTable and Dictionary in C#
- How to convert Dictionary to Hashtable in PowerShell?
- What is the difference between list and dictionary in C#?
- What is the difference between $ErrorActionPreference and $ErrorAction cmdlet in PowerShell ?
- Difference between HashTable and ConcurrentHashMap in Java
- Difference between HashMap and HashTable in Java.
- Difference between HashTable and HashMap in Java
- What is the difference between a python tuple and a dictionary?
- What is the difference between –Match, -Like and –Contains Operator in PowerShell?
- Working with Hashtable and Dictionary in C#
- What is the differences between HashMap and HashTable in Java
- Hashtable vs. Dictionary in C#
- What is the difference between the New-AZTag and Update-AZTag command in Azure PowerShell?
- Difference between PowerShell and CMD
