简体   繁体   中英

How to convert dictionary<string,int> to double array of their values in c#?

In my programming i have a challenge..

Dictionary<string,int> dic=new Dictionary<string,int>();

now i need to convert those dictionary "values" to 'Double' array.

i tried like this,

string[] strn=dic.Values.ToArray();

but not working. can any one please resolve my problem. Thanks in advance.

double[] dd = dic.Values.Select(i => (double)i).ToArray();

Try:

double[] strn = dic.Values.Select(v => (double)v).ToArray();

...and ignore people who are unkind enough to say "duh":)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM