Reputation: 788
I have an OrderedDictionaryKeyCollection comprising the following values:
[0] = "Alpha"
[1] = "Bravo"
[2] = "Charlie"
[3] = "Delta"
[4] = "Echo"
How do I access Key[2] value directly ("Charlie") without using ForEach and GetEnumerator?
Upvotes: 0
Views: 282
Reputation: 174485
You can use Select-Object -Index
:
$OrderedDictionary = [ordered]@{
Alpha = ""
Bravo = ""
Charlie = ""
Delta = ""
Echo = ""
}
$SecondKey = $OrderedDictionary.Keys |Select -Index 2
Upvotes: 2