top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to Get the Dictionary Key by value in C# ?

0 votes
94 views
How to Get the Dictionary Key by value in C# ?
posted May 7, 2016 by Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer
using System;
using System.Collections.Generic;
using System.Linq;

namespace ACCode
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, string> dictionaryItems= new Dictionary<string, string>()
            {
                {"1", "One"},
                {"2", "Two"},
                {"3", "Three"},
                {"4", "Three"},
                {"5", "Three"}
            };
            var dictValue = dictionaryItems.FirstOrDefault(x => x.Value == "Three").Key;
            Console.WriteLine(dictValue);
            Console.ReadLine();
        }       
    } 
}
answer May 7, 2016 by Shivaranjini
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...