Skip to content

Fix equality check between sb1 and sb2#12274

Merged
gewarren merged 3 commits into
dotnet:mainfrom
mahfeshar:patch-2
Feb 25, 2026
Merged

Fix equality check between sb1 and sb2#12274
gewarren merged 3 commits into
dotnet:mainfrom
mahfeshar:patch-2

Conversation

@mahfeshar

Copy link
Copy Markdown
Contributor

This PR/Issue corrects outdated information in the StringBuilder.Equals(StringBuilder) documentation to align it with modern .NET behavior (starting from .NET Core 3.0 through .NET 10).

Key Changes:

Updated section: Removed references to Capacity and MaxCapacity equality, as these properties are no longer part of the comparison logic in modern .NET versions.

Corrected Example Output: Updated the sample code's expected output for case b4. Previously, the example incorrectly stated that sb1.Equals(sb2) would return False when capacities differed. In modern .NET, this returns True as it performs an ordinal string comparison.

Consistency: Resolved the contradiction between the "Remarks" section (which correctly described the .NET Core 3.0+ behavior) and the "Returns/Example" sections which were still reflecting the legacy .NET Framework behavior.

Corrected the comparison result of sb1 and sb2 to reflect that they are equal.
@mahfeshar mahfeshar requested a review from a team as a code owner January 31, 2026 17:21
@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 31, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jan 31, 2026

@gewarren gewarren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @mahfeshar, sorry for the delay in reviewing. Can you also please update cap.vb and cap.fs?

@mahfeshar

Copy link
Copy Markdown
Contributor Author

Thanks for the review! No problem at all regarding the delay.
I’ve made the requested updates to cap.vb and cap.fs.

@mahfeshar

Copy link
Copy Markdown
Contributor Author

@mahfeshar please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

@gewarren gewarren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please update the output intros, for example line 49 in cap.cs, to "The example displays the following output on .NET (Core):"

Comment thread snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs Outdated
Comment thread snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs Outdated
Comment thread snippets/visualbasic/System.Text/StringBuilder/Capacity/cap.vb Outdated
@gewarren gewarren enabled auto-merge (squash) February 25, 2026 18:28
@gewarren gewarren merged commit 4cf8281 into dotnet:main Feb 25, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants