OrdereredDictionary<K,V> and the KeyNotFoundException

Open Beginner friendly
#12,621 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Quiet
Tech stack
csharp
Domain
documentation

Research direction

Open the generic OrderedDictionary<TKey,TValue> API page and its XML source at System.Collections.Generic/OrderedDictionary`2.xml. Read the indexer documentation and compare it with the non-generic OrderedDictionary behavior described in the issue. Done means the generic page clearly warns that a missing key throws KeyNotFoundException, while the non-generic version returns null.

Written by the indexing model from the issue text.

Description

area-System.Collections untriaged
Type of issue

Missing information

Description

It would be nice if the subtle difference between the indexers for the non-generic and generic OrderedDictionary classes was called out as something to be aware of.

In the non-generic version, the indexer returns null if the key isn't found.

In the generic version, the KeyNotFoundException is thrown if the key isn't found.

This subtlety bit us today as we recently updated the non-generic version to the generic version.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ordereddictionary-2.item?view=net-10.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Collections.Generic/OrderedDictionary`2.xml

Document Version Independent Id

fda90b9c-d6f5-e8a1-f381-46dd197f9890

Platform Id

59bdc0d2-f5e3-f0b9-0c27-d510734779b1

Article author

@dotnet-bot

Dominant language
C#
Stars
950
Forks
1.7k
Avg merge
3d 5h
Merged PRs (30d)
38

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/dotnet-api-docs

All issues in dotnet/dotnet-api-docs

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.