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

...