请问如何把Dictionary里的Key取出来放在List里
private IDictionary<string, double[]> GetDicLocation()
{
IDictionary<string, double[]> dicLocation = new Dictionary<string, double[]>();
//地址,纬度,经度
dicLocation.Add("住处", new double[] { 40.035846, 116.331788 });
dicLocation.Add("北京", new double[] { 39.960149, 116.223748 });
dicLocation.Add("武汉", new double[] { 30.574527, 114.269341 });
dicLocation.Add("恋湖", new double[] { 30.667586, 114.211785 });
dicLocation.Add("家乡", new double[] { 30.386623, 111.538029 });
return dicLocation;
}
现在有这么一个方法,要用Linq把里面Key取出来,放在一个List里,请问怎么做,谢谢!
------解决方案--------------------
dicLocation.Keys
的类型是Dictionary<(Of <(TKey, TValue>)>).KeyCollection
看看KeyCollection是不是够你使用了。
public sealed class KeyCollection : ICollection<TKey>, IEnumerable<TKey>, ICollection, IEnumerable
------解决方案--------------------
ToList();