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

Leave a Reply

Your email address will not be published.