I have this 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 to get the key of values that contains "[GC]"
Any idea how?
Thanks.
Use LINQ:
var result = Players.Where(p => p.Value.Contains("[GC]")).Select(p => p.Key);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With