c# - Get dictionary key if value contains string -


i have dictionary:

    static dictionary<int, string> players = new dictionary<int, string>();     dictionary.add(1, "chris [gc]");     dictionary.add(2, "john");     dictionary.add(3, "paul");     dictionary.add(4, "daniel [gc]"); 

i want key of values contains "[gc]"

any idea how?

thanks.

use query below.

   var itemswithgc = dictionary.where(d => d.value.contains("[gc]")).select(d => d.key).tolist();    foreach (var in itemswithgc)    {        console.writeline(i);    } 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -