Skip to content

Instantly share code, notes, and snippets.

@johnjohnsp1
Forked from adamdriscoll/Dictionary.ps1
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save johnjohnsp1/70893e3aea4579abfba1 to your computer and use it in GitHub Desktop.

Select an option

Save johnjohnsp1/70893e3aea4579abfba1 to your computer and use it in GitHub Desktop.
function Dictionary
{
param([Type[]]$Type, [Hashtable]$Hashtable)
$KeyType = $Type[0]
$ValueType = $Type[1]
$Dictionary = New-Object -TypeName "System.Collections.Generic.Dictionary[$KeyType,$ValueType]"
$Hashtable.GetEnumerator() | % {
$Dictionary.Add($_.Key, $_.Value)
}
$Dictionary
}
Dictionary System.DayOfWeek, String @{
'Saturday' = "Caturday";
'Sunday' = "Funday";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment