Skip to content

Fixes to system.string #4058

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

Merged
merged 2 commits into from
Apr 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions xml/System/String.xml
Original file line number Diff line number Diff line change
Expand Up @@ -784,20 +784,6 @@ Examples of instantiating strings:
[!code-cpp[stringexample1#2](~/samples/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp#2)]
[!code-csharp[stringexample1#2](~/samples/snippets/csharp/VS_Snippets_CLR/stringexample1/CS/source.cs#2)]

<a name="Versions"></a>
## Version information
.NET Framework
All overloads are supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile
All overloads are supported in: 4, 3.5 SP1

Portable Class Library
All overloads without an <xref:System.SByte>`*` parameter are supported

.NET for Windows Store apps
All overloads without an <xref:System.SByte>`*` parameter are supported in: Windows 8

]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -7839,13 +7825,14 @@ The `comparisonType` parameter is a <xref:System.StringComparison> enumeration m

Compare this method to the <xref:System.String.IsInterned%2A> method.

## Version Considerations
## Version considerations

In the [!INCLUDE[net_v35SP1_long](~/includes/net-v35sp1-long-md.md)], the <xref:System.String.Intern%2A> method reverts to its behavior in the .NET Framework 1.0 and 1.1 with regard to interning the empty string. In the following example, the variable `str1` is assigned a reference to <xref:System.String.Empty?displayProperty=nameWithtype>, and the variable `str2` is assigned the reference to <xref:System.String.Empty?displayProperty=nameWithtype> that is returned by calling the <xref:System.String.Intern%2A> method after converting a <xref:System.Text.StringBuilder> object whose value is <xref:System.String.Empty?displayProperty=nameWithtype> to a string. Then the references contained in `str1` and `str2` are compared for equality.

[!code-csharp[System.String.Intern#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.String.Intern/cs/Intern2.cs#2)]
[!code-vb[System.String.Intern#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Intern/vb/Intern2.vb#2)]

In the [!INCLUDE[net_v10_short](~/includes/net-v10-short-md.md)], [!INCLUDE[net_v11_short](~/includes/net-v11-short-md.md)], and [!INCLUDE[net_v35SP1_short](~/includes/net-v35sp1-short-md.md)], `str1` and `str2` are equal. In the [!INCLUDE[net_v20sp1_long](~/includes/net-v20sp1-long-md.md)] and [!INCLUDE[net_v30_long](~/includes/net-v30-long-md.md)], `str1` and `str2` are not equal.
In the [!INCLUDE[net_v20sp1_long](~/includes/net-v20sp1-long-md.md)] and [!INCLUDE[net_v30_long](~/includes/net-v30-long-md.md)], `str1` and `str2` are not equal. In all other versions, `str1` and `str2` are equal.

## Performance Considerations
If you are trying to reduce the total amount of memory your application allocates, keep in mind that interning a string has two unwanted side effects. First, the memory allocated for interned <xref:System.String> objects is not likely to be released until the common language runtime (CLR) terminates. The reason is that the CLR's reference to the interned <xref:System.String> object can persist after your application, or even your application domain, terminates. Second, to intern a string, you must first create the string. The memory used by the <xref:System.String> object must still be allocated, even though the memory will eventually be garbage collected.
Expand Down Expand Up @@ -12632,11 +12619,11 @@ The following example defines a `StripStartTags` method that uses the <xref:Syst
<summary>Compares this instance with a specified <see cref="T:System.Object" /> and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified <see cref="T:System.Object" />.</summary>
<returns>A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the <paramref name="value" /> parameter.

<list type="table"><listheader><term>Value</term><description>Condition</description></listheader><item><term>Less than zero</term><description>This instance precedes <paramref name="value" />.</description></item><item><term>Zero</term><description>This instance has the same position in the sort order as <paramref name="value" />.</description></item><item><term>Greater than zero</term><description>This instance follows <paramref name="value" />.
<list type="table"><listheader><term>Value</term><description>Condition</description></listheader><item><term>Less than zero</term><description>This instance precedes <paramref name="value" />.</description></item><item><term>Zero</term><description>This instance has the same position in the sort order as <paramref name="value" />.</description></item><item><term>Greater than zero</term><description>This instance follows <paramref name="value" />.

-or-
-or-

<paramref name="value" /> is <see langword="null" />.</description></item></list></returns>
<paramref name="value" /> is <see langword="null" />.</description></item></list></returns>
<remarks>
<format type="text/markdown"><![CDATA[

Expand Down