Dictionaiy
A Dictionary is een collection van key value pairs, deze declareer je als volgt:
Dictionary colorStrings = new Dictionary();
Met Add voeg je eenvoudig toe aan de dictiopnary:
colorStrings.Add(Color.Black, Color.Black.ToString()); colorStrings.Add(Color.Blue, Color.Blue.ToString()); colorStrings.Add(Color.Red, Color.Red.ToString());
Met een foreach of met gebruik van de index [] lees je de objecten weer uitp>
foreach (KeyValuePair color in colorStrings) { Console.WriteLine(color.Key.GetBrightness().ToString()); }