Skip to content

Instantly share code, notes, and snippets.

@JKamsker
Created January 2, 2017 16:14
Show Gist options
  • Save JKamsker/be1ce2073761fb96d126e528275ab191 to your computer and use it in GitHub Desktop.
Save JKamsker/be1ce2073761fb96d126e528275ab191 to your computer and use it in GitHub Desktop.
public static Dictionary<U,T> dictConvert<U,T>(Dictionary<U,object> input)
{
var outp = new Dictionary<U, T>();
foreach (var item in input.Keys)
{
if (input[item].GetType() != typeof(T))
continue;
if (!outp.ContainsKey(item))
outp.Add(item, (T)input[item]);
else
outp[item] = (T)input[item];
}
return outp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment