Skip to content

OrdereredDictionary<K,V> and the KeyNotFoundException #12621

@matman13

Description

@matman13

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions