Skip to content

Commit b3d0280

Browse files
committed
some tweaks
1 parent 72e7857 commit b3d0280

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/core/compatibility/core-libraries/9.0/string-trim.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: "Breaking change: String.Trim(params ReadOnlySpan<char>) removed"
3-
description: Learn about the breaking change in core .NET libraries where the String.Trim(params ReadOnlySpan<char>) method has been removed due to potential behavioral changes.
2+
title: "Breaking change: String.Trim*(params ReadOnlySpan<char>) overloads removed"
3+
description: Learn about the breaking change in core .NET libraries where the String.Trim*(params ReadOnlySpan<char>) methods have been removed due to potential behavioral changes.
44
ms.date: 11/5/2024
55
ai-usage: ai-assisted
66
---
77

8-
# String.Trim(params ReadOnlySpan\<char>) overload removed
8+
# String.Trim*(params ReadOnlySpan\<char>) overloads removed
99

10-
`ReadOnlySpan<char>` is used for two different things in the .NET ecosystem:
10+
In the .NET ecosystem, `ReadOnlySpan<char>` can represent:
1111

1212
- A specific sequence of characters, often as a slice of a larger <xref:System.String?displayProperty=fullName> instance.
1313
- A collection of single characters, often as a slice of a `char[]`.
@@ -37,7 +37,7 @@ public static class SomeExtensions {
3737
}
3838
```
3939

40-
For existing .NET runtimes, this extension method removes the specified sequence from the end of the string. However, due to the overload resolution rules of C#, `"12345!!!!".TrimEnd("!!!")` will prefer the new method overload over the existing extension method, and change the result from `"12345!"` (removing only a full set of three exclamation marks) to `"12345"` (removing all exclamation marks from the end).
40+
For existing .NET runtimes, this extension method removes the specified sequence from the end of the string. However, due to the overload resolution rules of C#, `"12345!!!!".TrimEnd("!!!")` will prefer the new `TrimEnd` overload over the existing extension method, and change the result from `"12345!"` (removing only a full set of three exclamation marks) to `"12345"` (removing all exclamation marks from the end).
4141

4242
To resolve this break, there were two possible paths: Introduce an instance method `public string TrimEnd(string trimString)` that's an even better target, or remove the new method. The first option carries additional risk, as it needs to decide whether it returns one instance of the target string or all of them. And there are undoubtedly callers with existing code that uses each approach. Therefore, the second option was the most appropriate choice for this stage of the release cycle.
4343

0 commit comments

Comments
 (0)