list - User input creating Dictionary Key (C#) -


student here.

working on current c# project.

i have create list<card> of playing cards, , dictionary<string, list<card>>.

list gets created independently, , dictionary holds collections of cards. cards can added or removed collections.

i'm having trouble creating dictionary key based off user input

the error while program running, , type in name of key want create.

object reference not set instance of object.

here code block:

console.write("what name of collection? "); string collectionname = console.readline(); bool found = currentmanager.collections.containskey(collectionname); if (!found)  {     currentmanager.collections.add(collectionname, null);  } else     console.writeline("that collection name has been used."); 

i using collectionmanager class, dictionary named _collections. being called here:

public dictionary<string, list<card>> collections     {                 {             return _collections;         }         set         {             _collections = value;         }     } 

is _collections reference initialized dictionary instance? based on error message, looks _collections not pointing instance.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -