How to get dictionary value by key in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main()
        {
            var dic = new Dictionary<string, int>();
            dic.Add("vb.net", 9);
            dic.Add("java", 6);
            dic.Add("php", 7);
            dic.Add("python", 3);
            dic.Add("c#", 4);

            Console.WriteLine(dic["c#"]);
            Console.WriteLine(dic["php"]);
        }
    }
}


/*
run:
   
4
7
    
*/

 



answered Oct 17, 2018 by avibootz

Related questions

5 answers 222 views
1 answer 138 views
1 answer 109 views
109 views asked Dec 10, 2022 by avibootz
...