I want to store string, ConsoleColor pairs like

dataStructure.Add(new KeyValuePair<string, ConsoleColor>("Red", ConsoleColor.Red))

I tried List but it did not seem to work;

List<KeyValuePair<string, ConsoleColor>> colorList;
            colorList.Add(new KeyValuePair<string, ConsoleColor>("Red", ConsoleColor.Red));
            colorList.Add(new KeyValuePair<string, ConsoleColor>("Yellow", ConsoleColor.Yellow));
            colorList.Add(new KeyValuePair<string, ConsoleColor>("Green", ConsoleColor.Green));
            colorList.Add(new KeyValuePair<string, ConsoleColor>("Blue", ConsoleColor.Blue));
            colorList.Add(new KeyValuePair<string, ConsoleColor>("White", ConsoleColor.White));

with the error "An unhandled exception of type 'System.NullReferenceException' occurred in BrainSalad.exe".

Can you help me with this issue?

You haven't initialised your List.

Also, there is a pre-defined collection for this called "Dictionary" Dictionary<String, ConsoleColor> colorList = new Dictionary<String, ConsoleColor>();

Thanks for the lightning fast and correct reply
This question has already been answered. Start a new discussion instead.