Skip to content

Latest commit

 

History

History
 
 

Dictionary-Count-Keys-Values

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Dictionary Count, Keys, Values may misbehave

Given a hashtable or dictionary, it looks natural accessing its properties Count, Keys, Values using the classic dot notation. Unfortunately, in PowerShell the dot notation is also used for accessing dictionary values by keys, and keys have higher precedence than properties with the same names.

Workaround

The reliable workaround seems to be accessing properties Count, Keys, Values as .get_Count(), .get_Keys(), .get_Values() respectively.

Workarounds like .PSBase.Count are not ideal for the same issue. If a hashtable or dictionary contains the key PSBase then it's a problem.

Scripts