What does the [string] indexer of Dictionary return when the key doesn’t exist in the Dictionary? I am new to C# and I can’t seem to find a reference as good as the Javadocs.
Do I get null, or do I get an exception?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you mean the indexer of a
Dictionary<string,SomeType>, then you should see an exception (KeyNotFoundException). If you don’t want it to error: