Cast from one generic IDictionary to another

  • Thread starter Thread starter pierre.k
  • Start date Start date
P

pierre.k

Hello,
how can I do a cast like
IDictionary<int, string> as IDictionary<object, string> ?

Thanks in advance for your help,
pierre.k
 
You can't just cast a generic dictionary with a different key data type. You
can however create the second dictionary, copy the original keys to an int[]
using the Keys.CopyTo method, go through them and populate the new
dictionary with the old data.

Stanimir Stoyanov | www.stoyanoff.info
 
Back
Top