Dictionary<string, string> dic = GetRoleDescriptions();
string key = dic.FirstOrDefault(x => x.Value == ddlSearchRoleDes.SelectedItem.Text.Trim().ToUpper()).Key;

Dictionary——通过value找Key的更多相关文章

  1. System.ArgumentException: 已添加了具有相同键的项。(An item with the same key has already been added) 在 System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) 在 System.Web.Mvc.Js

    最近将一个项目从ASP.NET MVC 3升级至刚刚发布的ASP.NET MVC 5.1,升级后发现一个ajax请求出现了500错误,日志中记录的详细异常信息如下: System.ArgumentEx ...

  2. 【RF库Collections测试】Dictionary Should Not Contain Key

    Name:Dictionary Should Not Contain KeySource:Collections <test library>Arguments:[ dictionary ...

  3. python中字典以key排序,以value排序。以及通过value找key的方式

    1.sorted函数首先介绍sorted函数,sorted(iterable,key,reverse),sorted一共有iterable,key,reverse这三个参数. 其中iterable表示 ...

  4. redis 中用正则找key

    获取 redis 中所有的 key 可用使用 *. redis 127.0.0.1:6379> KEYS * 1) "w3c3" 2) "w3c1" 3) ...

  5. C#中的Dictionary类,默认key是区分大小写的

    在C#中定义一个Dictionary Dictionary<string,string> dictionary = new Dictionary<string,string>( ...

  6. map集合根据value找key,默认取第一个key

    private static String getKey(Map<String,String> map,String value){ String key=""; fo ...

  7. c# Dictionary拓展2个key得到1个value

    using System.Collections.Generic; using System.Collections; Dictionary<Tuple<int, int>, int ...

  8. 用memcached的时候找key找不到,写了个命令来找找

    for i in $(seq 30); do echo "stats cachedump $i 0" | nc 192.168.88.150 11211 | grep groupS ...

  9. (转).Net中自定义类作为Dictionary的key详解

    在定义数据结构时,Dictionary提供了快速查找数据的功能,另外Dictionary< TKey, TValue >属于key-value键值对数据结构,提供了泛型的灵活性,是数据结构 ...

随机推荐

  1. java集合框架小结

    总结例如以下: 1.假设要求线程安全的, 使用Vector.Hashtable 2.假设不要求线程安全,应该使用ArrayList.LinkedList.HashMap 3.假设要求有映射关系,键值对 ...

  2. HTTP——请求和响应格式

    HTTP请求格式:<request-line><headers><blank line>[<request-body>]说明:第一行必须是一个请求行(r ...

  3. CSS Flexible 布局兼容性以及解决方案

    1.兼容性 https://caniuse.com/#feat=flexbox IE11以及以下不支持. 2.解决方案 flexibility库 https://github.com/jonathan ...

  4. 使用sql语句实现添加、删除约束

    --主键约束(Primary Key constraint):要求主键列的数据唯一,并且不允许为空. --唯一约束(Unique Constraint):要求该列唯一,允许为空,但只能出现一个空值. ...

  5. H5页面在IOS下不会自动播放音乐的坑

    document.addEventListener(‘DOMContentLoaded‘, function () { function audioAutoPlay() { var audio = d ...

  6. 转 iOS:NSAttributedString

    NSAttributedString: http://blog.csdn.net/kmyhy/article/details/8895638 CTFramesetterSuggestFrameSize ...

  7. AMQP 协议介绍

    RabbitMQ 是遵从AMQP 协议的, 换句话说, RabbitMQ 就是AMQP 协议的Erlang 的实现(当然RabbitMQ 还支持STOMP2 .MQTT3 等协议) 0 AMQP 的模 ...

  8. 李洪强iOS开发之OC[002] - OC中注释以及@符号的使用

  9. Mockito - Wanted but not invoked: Actually, there were zero interactions with this mock

    要测试的类:IndexController.java 代码: @Mock private TemplateWrapper templateWrapper = spy(new TemplateWrapp ...

  10. ArrayList和Vector性能对比

    测试条件: 循环次数:1千万次 元素个数:1000个 测试结果: 总结:ArrayList获取元素非常快,不过添加元素没有Vector快,两者各有优势,Vector是线程安全的,而ArrayList是 ...