Skip to content

Commit ca1a41c

Browse files
authored
Fix minor issues in String.Substring documentation (dotnet#8597)
1 parent fb84057 commit ca1a41c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

xml/System/String.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13153,12 +13153,12 @@ The following example defines a `StripStartTags` method that uses the <xref:Syst
1315313153
<format type="text/markdown"><![CDATA[
1315413154

1315513155
## Remarks
13156-
You call the <xref:System.String.Substring(System.Int32)> method to extract a substring from a string that begins at a specified character position and ends at the end of the string. The starting character position is a zero-based; in other words, the first character in the string is at index 0, not index 1. To extract a substring that begins at a specified character position and ends before the end of the string, call the <xref:System.String.Substring(System.Int32%2CSystem.Int32)> method.
13156+
You call the <xref:System.String.Substring(System.Int32)> method to extract a substring from a string that begins at a specified character position and ends at the end of the string. The starting character position is zero-based; in other words, the first character in the string is at index 0, not index 1. To extract a substring that begins at a specified character position and ends before the end of the string, call the <xref:System.String.Substring(System.Int32%2CSystem.Int32)> method.
1315713157

1315813158
> [!NOTE]
1315913159
> This method does not modify the value of the current instance. Instead, it returns a new string that begins at the `startIndex` position in the current string.
1316013160

13161-
To extract a substring that begins with a particular character or character sequence, call a method such as <xref:System.String.IndexOf%2A> or <xref:System.String.IndexOf%2A> to get the value of `startIndex`. The second example illustrates this; it extracts a key value that begins one character position after the "=" character.
13161+
To extract a substring that begins with a particular character or character sequence, call a method such as <xref:System.String.IndexOf%2A> or <xref:System.String.IndexOf%2A> to get the value of `startIndex`. The second example illustrates this; it extracts a key value that begins one character position after the `=` character.
1316213162

1316313163
If `startIndex` is equal to zero, the method returns the original string unchanged.
1316413164
## Examples
@@ -13169,7 +13169,7 @@ The following example defines a `StripStartTags` method that uses the <xref:Syst
1316913169
:::code language="fsharp" source="~/snippets/fsharp/System/String/Substring/Substring10.fs" id="Snippet10":::
1317013170
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.String.Substring/vb/Substring10.vb" id="Snippet10":::
1317113171

13172-
The following example uses the <xref:System.String.Substring%2A> method to separate key/value pairs that are delimited by an equals ("=") character.
13172+
The following example uses the <xref:System.String.Substring%2A> method to separate key/value pairs that are delimited by an equals (`=`) character.
1317313173

1317413174
:::code language="csharp" source="~/snippets/csharp/System/String/Substring/Substring1.cs" interactive="try-dotnet-method" id="Snippet1":::
1317513175
:::code language="fsharp" source="~/snippets/fsharp/System/String/Substring/Substring1.fs" id="Snippet1":::
@@ -13250,32 +13250,32 @@ The following example defines a `StripStartTags` method that uses the <xref:Syst
1325013250
<format type="text/markdown"><![CDATA[
1325113251

1325213252
## Remarks
13253-
You call the <xref:System.String.Substring(System.Int32%2CSystem.Int32)> method to extract a substring from a string that begins at a specified character position and ends before the end of the string. The starting character position is a zero-based; in other words, the first character in the string is at index 0, not index 1. To extract a substring that begins at a specified character position and continues to the end of the string, call the <xref:System.String.Substring(System.Int32)> method.
13253+
You call the <xref:System.String.Substring(System.Int32%2CSystem.Int32)> method to extract a substring from a string that begins at a specified character position and ends before the end of the string. The starting character position is zero-based; in other words, the first character in the string is at index 0, not index 1. To extract a substring that begins at a specified character position and continues to the end of the string, call the <xref:System.String.Substring(System.Int32)> method.
1325413254

1325513255
> [!NOTE]
1325613256
> This method does not modify the value of the current instance. Instead, it returns a new string with `length` characters starting from the `startIndex` position in the current string.
1325713257

13258-
The `length` parameter represents the total number of characters to extract from the current string instance. This includes the starting character found at index `startIndex`. In other words, the <xref:System.String.Substring%2A> method attempts to extract characters from index `startIndex` to index `startIndex` + `length` - 1.
13258+
The `length` parameter represents the total number of characters to extract from the current string instance. This includes the starting character found at index `startIndex`. In other words, the <xref:System.String.Substring%2A> method attempts to extract characters from index `startIndex` to index `startIndex` + `length` - 1.
1325913259

13260-
To extract a substring that begins with a particular character or character sequence, call a method such as <xref:System.String.IndexOf%2A> or <xref:System.String.LastIndexOf%2A> to get the value of `startIndex`.
13260+
To extract a substring that begins with a particular character or character sequence, call a method such as <xref:System.String.IndexOf%2A> or <xref:System.String.LastIndexOf%2A> to get the value of `startIndex`.
1326113261

13262-
If the substring extends from `startIndex` to a specified character sequence, you can call a method such as <xref:System.String.IndexOf%2A> or <xref:System.String.LastIndexOf%2A> to get the index of the ending character or character sequence. You can then convert that value to an index position in the string as follows:
13262+
If the substring should extend from `startIndex` to a specified character sequence, you can call a method such as <xref:System.String.IndexOf%2A> or <xref:System.String.LastIndexOf%2A> to get the index of the ending character or character sequence. You can then convert that value to an index position in the string as follows:
1326313263

13264-
- If you've searched for a single character that is to mark the end of the substring, the `length` parameter equals `endIndex` - `startIndex` + 1, where `endIndex` is the return value of the <xref:System.String.IndexOf%2A> or <xref:System.String.IndexOf%2A> method. The following example extracts a continuous block of "b" characters from a string.
13264+
- If you've searched for a single character that is to mark the end of the substring, the `length` parameter equals `endIndex` - `startIndex` + 1, where `endIndex` is the return value of the <xref:System.String.IndexOf%2A> or <xref:System.String.LastIndexOf%2A> method. The following example extracts a continuous block of "b" characters from a string.
1326513265

1326613266
:::code language="csharp" source="~/snippets/csharp/System/String/Substring/Substring2.cs" interactive="try-dotnet-method" id="Snippet2":::
1326713267
:::code language="fsharp" source="~/snippets/fsharp/System/String/Substring/Substring2.fs" id="Snippet2":::
1326813268
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.String.Substring/vb/Substring2.vb" id="Snippet2":::
1326913269

13270-
- If you've searched for multiple characters that are to mark the end of the substring, the `length` parameter equals `endIndex` + `endMatchLength` - `startIndex`, where `endIndex` is the return value of the <xref:System.String.IndexOf%2A> or <xref:System.String.IndexOf%2A> method, and `endMatchLength` is the length of the character sequence that marks the end of the substring. The following example extracts a block of text that contains an XML `<definition>` element.
13270+
- If you've searched for multiple characters that are to mark the end of the substring, the `length` parameter equals `endIndex` + `endMatchLength` - `startIndex`, where `endIndex` is the return value of the <xref:System.String.IndexOf%2A> or <xref:System.String.LastIndexOf%2A> method, and `endMatchLength` is the length of the character sequence that marks the end of the substring. The following example extracts a block of text that contains an XML `<definition>` element.
1327113271

1327213272
:::code language="csharp" source="~/snippets/csharp/System/String/Substring/Substring3.cs" interactive="try-dotnet-method" id="Snippet3":::
1327313273
:::code language="fsharp" source="~/snippets/fsharp/System/String/Substring/Substring3.fs" id="Snippet3":::
1327413274
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.String.Substring/vb/Substring3.vb" id="Snippet3":::
1327513275

13276-
- If the character or character sequence is not included in the end of the substring, the `length` parameter equals `endIndex` - `startIndex`, where `endIndex` is the return value of the <xref:System.String.IndexOf%2A> or <xref:System.String.IndexOf%2A> method.
13276+
- If the character or character sequence is not included in the end of the substring, the `length` parameter equals `endIndex` - `startIndex`, where `endIndex` is the return value of the <xref:System.String.IndexOf%2A> or <xref:System.String.LastIndexOf%2A> method.
1327713277

13278-
If `startIndex` is equal to zero and equals the length of the current string, the method returns the original string unchanged.
13278+
If `startIndex` is equal to zero and `length` equals the length of the current string, the method returns the original string unchanged.
1327913279

1328013280
## Examples
1328113281
The following example illustrates a simple call to the <xref:System.String.Substring(System.Int32%2CSystem.Int32)> method that extracts two characters from a string starting at the sixth character position (that is, at index five).
@@ -13286,7 +13286,7 @@ The following example defines a `StripStartTags` method that uses the <xref:Syst
1328613286

1328713287
The following example uses the <xref:System.String.Substring(System.Int32%2CSystem.Int32)> method in the following three cases to isolate substrings within a string. In two cases the substrings are used in comparisons, and in the third case an exception is thrown because invalid parameters are specified.
1328813288

13289-
- It extracts the single character and the third position in the string (at index 2) and compares it with a "c". This comparison returns `true`.
13289+
- It extracts the single character at the third position in the string (at index 2) and compares it with a "c". This comparison returns `true`.
1329013290

1329113291
- It extracts zero characters starting at the fourth position in the string (at index 3) and passes it to the <xref:System.String.IsNullOrEmpty%2A> method. This returns true because the call to the <xref:System.String.Substring%2A> method returns <xref:System.String.Empty?displayProperty=nameWithType>.
1329213292

@@ -13296,7 +13296,7 @@ The following example defines a `StripStartTags` method that uses the <xref:Syst
1329613296
:::code language="fsharp" source="~/snippets/fsharp/System/String/Substring/source.fs" id="Snippet1":::
1329713297
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic String.Substring1 Example/VB/source.vb" id="Snippet1":::
1329813298

13299-
The following example uses the <xref:System.String.Substring%2A> method to separate key/value pairs that are delimited by an equals ("=") character.
13299+
The following example uses the <xref:System.String.Substring%2A> method to separate key/value pairs that are delimited by an equals (`=`) character.
1330013300

1330113301
:::code language="csharp" source="~/snippets/csharp/System/String/Substring/Substring1.cs" interactive="try-dotnet-method" id="Snippet1":::
1330213302
:::code language="fsharp" source="~/snippets/fsharp/System/String/Substring/Substring1.fs" id="Snippet1":::

0 commit comments

Comments
 (0)