dotnet / dotnet/dotnet-api-docs

Comparer<T> code snippet issues

Open
#10,008 1 comment 0 reactions 0 assignees View on GitHub
area-System.Collections Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.comparer-1?view=net-8.0#examples

In the examples code snippet, the comment above the declaration of `LengthFirst` talks about an explicit interface implementation, but I don't see this anywhere in the snippet.

The snippet has some other issues too, including:
1. Local variables named in pascal case (`Boxes`, `LengthFirst`, `BoxA` and `BoxB`)
2. Ancient string formatting (should be using string interpolation instead)
3. Unused variables (`defComp`, `bc`)
4. Weird variable names (why `bx` instead of `box`, why `defComp` instead of `defaultComparer`, what is `bc`?)
5. The `Compare` methods could use some variables for clarity and code quality
6. Use collection expression for creating the list

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.