How do you access the value for key 'City' in a hash table named $info?
easy📝 Conceptual Q2 of 15
PowerShell - Variables and Data Types
How do you access the value for key 'City' in a hash table named $info?
A$info['City']
B$info.City
C$info->City
D$info(City)
Step-by-Step Solution
Solution:
Step 1: Recall the syntax for accessing hash table values
In PowerShell, hash table values are accessed using square brackets and quotes around the key.
Step 2: Evaluate each option
$info['City'] uses $info['City'], which is the correct syntax. $info.City is incorrect because dot notation does not work for hash tables. Options C and D are invalid syntax.
Final Answer:
$info['City'] -> Option A
Quick Check:
Access hash table value = $hash['key'] [OK]
Quick Trick:Use square brackets and quotes to access hash table keys [OK]
Common Mistakes:
Using dot notation for hash tables
Using parentheses instead of brackets
Omitting quotes around keys
Master "Variables and Data Types" in PowerShell
9 interactive learning modes - each teaches the same concept differently