Get value from dictionary c#

Get value from dictionary c#

 

using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        Dictionary<string, int> dictionary = new Dictionary<string, int>();

        dictionary.Add("a", 1);
        dictionary.Add("b", 5);

        if (dictionary.ContainsKey("a"))
        {
            int value = dictionary["a"];
            Console.WriteLine(value);
        }
        
        if (!dictionary.ContainsKey("b"))
        {
            Console.WriteLine(true);
        }
        Console.ReadKey();
    }
}
 

2021-10-03