Created
May 13, 2020 21:52
-
-
Save FurkanKozen/520fa83aec74b63665e5adce966a9c53 to your computer and use it in GitHub Desktop.
Finding the key by its value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var dict = new Dictionary<string, int>(); | |
dict.Add("A", 25); | |
dict.Add("B", 35); | |
dict.Add("C", 45); | |
var key = dict.Single(kv => kv.Value == 35).Key; | |
Console.WriteLine(key); | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment