Don’t do that #14: Use Add method when creating a hashtable with multiple elements

By | April 10, 2015

Don’t do that: An empty hashtable is created and then the elements are added.


Do that: In this scenario, I prefer to create the hashtable with the elements (key/value), not after the creation: it’s faster and more practical.

Note: The attribute “ordered” is optional (it exists since Powershell v3 and creates an ordered dictionary).

hashtable-ordered


previous-buttonnext-button

One thought on “Don’t do that #14: Use Add method when creating a hashtable with multiple elements

  1. Pingback: Don’t do that #15 : Use Add method to multiple elements when creating an array - Powershell Guru

Leave a Reply

Your email address will not be published. Required fields are marked *