根据索引获取Dictionary的key和value值
2015-12-12 11:43
525 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DictionaryHelper
{
public class DictionaryHelper<K,V>
{
public static K getKey(Dictionary<K, V> dict, int index)
{
K k=default(K);
int sum = 0;
foreach (K key in dict.Keys)
{
sum++;
if (sum == (index+1))
return key;
}
return k;
}
public static V getValue(Dictionary<K, V> dict, int index)
{
V v = default(V);
int sum = 0;
foreach (V value in dict.Values)
{
sum++;
if (sum == (index+1))
return value;
}
return v;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DictionaryHelper
{
public class DictionaryHelper<K,V>
{
public static K getKey(Dictionary<K, V> dict, int index)
{
K k=default(K);
int sum = 0;
foreach (K key in dict.Keys)
{
sum++;
if (sum == (index+1))
return key;
}
return k;
}
public static V getValue(Dictionary<K, V> dict, int index)
{
V v = default(V);
int sum = 0;
foreach (V value in dict.Values)
{
sum++;
if (sum == (index+1))
return value;
}
return v;
}
}
}
相关文章推荐
- UITextKit框架的学习(一)
- UICollectionView 瀑布流 初级
- uitableView 选择跳过后, 跳回 颜色变化 问题
- MIUI 判断悬浮窗权限
- 安装程序找不到office.zh-cn\OfficeMUI.msi。请浏览确定有效的安装源,然后单击”确定“。
- Java并发包中的同步队列SynchronousQueue实现原理
- BlockingQueue解析
- Hbuilder快捷入门
- UI中的继承源图
- hdu 3530 Subsequence 单调队列
- MUI之父页面刷新
- 关于uitableviewcell的accessoryType属性
- Legacy UEFI启动的比较
- BOIS模式 UEFI启动与Legacy启动鉴别
- 如何使用java自动生成数据表id,java.util.UUID类
- UEFI:BIOS下一代
- UI中的自适应高度
- MUI 版本更新
- 288. Unique Word Abbreviation
- ue4内存管理