Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA2251: Use String.Equals over String.Compare #10296

Open
Tracked by #10270
himgoyalmicro opened this issue Jan 16, 2025 · 0 comments · May be fixed by #10144
Open
Tracked by #10270

CA2251: Use String.Equals over String.Compare #10296

himgoyalmicro opened this issue Jan 16, 2025 · 0 comments · May be fixed by #10144
Assignees
Labels
area-Styling Indicates if an issue or a PR is for style changes 🚧 work in progress

Comments

@himgoyalmicro
Copy link
Contributor

himgoyalmicro commented Jan 16, 2025

Link to the issue description: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2251

Rule Description

String.Compare is designed to produce a total-order comparison that can be used for sorting. If you only care whether the strings are equal, it is both clearer and likely faster to use an equivalent overload of String.Equals.

@himgoyalmicro himgoyalmicro changed the title CA2251 CA2251: Use String.Equals over String.Compare Jan 16, 2025
@himgoyalmicro himgoyalmicro added the area-Styling Indicates if an issue or a PR is for style changes label Jan 16, 2025
@himgoyalmicro himgoyalmicro self-assigned this Jan 16, 2025
@himgoyalmicro himgoyalmicro linked a pull request Jan 16, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Styling Indicates if an issue or a PR is for style changes 🚧 work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant