Connecting Tech Pros Worldwide Forums | Help | Site Map

Cast from one generic IDictionary to another

pierre.k
Guest
 
Posts: n/a
#1: Jul 16 '08
Hello,
how can I do a cast like
IDictionary<int, stringas IDictionary<object, string ?

Thanks in advance for your help,
pierre.k

Stanimir Stoyanov
Guest
 
Posts: n/a
#2: Jul 16 '08

re: Cast from one generic IDictionary to another


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

"pierre.k" <petr.krebs@gmail.comwrote in message
news:91380878-51a9-42ac-88b5-66d61c6e802a@c65g2000hsa.googlegroups.com...
Quote:
Hello,
how can I do a cast like
IDictionary<int, stringas IDictionary<object, string ?
>
Thanks in advance for your help,
pierre.k
Closed Thread