Skip to content

Index Initializers section is inaccurate #5169

@drewjcooper

Description

@drewjcooper

In the Index initializers section, the initial text about collection initializers seems to imply that there was no way to initialize a Dictionary<,> prior to the new C# 6.0 syntax. This is incorrect. The following code is semantically equivalent to the index initializer example in the document.

private Dictionary<int, string> webErrors = new Dictionary<int, string>
{
    { 404, "Page not Found" },
    { 302, "Page moved, but left a forwarding address." },
    { 500, "The web server can't come out to play today." }
};

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions