Answers for "find in Dictionary c#"

C#
6

access dic by key c#

using System;
using System.Collections.Generic;

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

        dictionary.Add("apple", 1);
        dictionary.Add("windows", 5);

        // See whether Dictionary contains this string.
        if (dictionary.ContainsKey("apple"))
        {
            int value = dictionary["apple"];
            Console.WriteLine(value);
        }

        // See whether it contains this string.
        if (!dictionary.ContainsKey("acorn"))
        {
            Console.WriteLine(false);
        }
    }
}
Posted by: Guest on June-20-2020
0

c# find in dictionary

if (_tags.TryGetValue(tag, out string myValue))
{
    // use myValue;
}
// use myValue, still in scope, null if not found
Posted by: Guest on July-21-2021
0

find the values of dictionaries in C sharp

//sets the dictionary item, "dictionary item" to 20
dictionary["dictionary item"] = 20;
Posted by: Guest on November-23-2020

C# Answers by Framework

Browse Popular Code Answers by Language