How to

get values from dictionary

Published: 27. October 2011 | Updated: 27. October 2011
License: Microsoft Public License (MS-PL)
Categories: Collections
Tags: Basics C# Collections
Was this snippet helpful for you? YESYES / NONO

Import namespaces

using System.Collections.Generic;
using System.Linq;

Code

var dictionary = new Dictionary<int, string>();

dictionary.Add(1, "a");
dictionary.Add(3, "c");
dictionary.Add(5, "e");

var values = dictionary.Values.ToArray();

foreach (string value in values)
{
    Console.WriteLine(value);
}
Console Output:
a
c
e
Send us feedback about this snippet »



Related Snippets: