Skip to content

Commit 1471f24

Browse files
committed
fix remark about empty array
1 parent 7d4d432 commit 1471f24

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
// <Snippet1>
2-
using System;
1+
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
8-
char[] chars = { 'a', 'e', 'i', 'o', 'u', 'y',
7+
// <Snippet1>
8+
char[] chars = { 'a', 'e', 'i', 'o', 'u', 'y',
99
'A', 'E', 'I', 'O', 'U', 'Y' };
1010
String s = "The long and winding road...";
11-
Console.WriteLine("The first vowel in \n {0}\nis found at position {1}",
12-
s, s.IndexOfAny(chars) + 1);
11+
Console.WriteLine($"The first vowel in \n {s}\nis found at index {s.IndexOfAny(chars)}");
12+
13+
// The example displays the following output:
14+
// The first vowel in
15+
// The long and winding road...
16+
// is found at index 2
17+
// </Snippet1>
1318
}
1419
}
15-
// The example displays the following output:
16-
// The first vowel in
17-
// The long and winding road...
18-
// is found at position 3
19-
// </Snippet1>

snippets/fsharp/System/String/IndexOfAny/IndexOfAny1.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ module IndexOfAny1.fs
33
let chars = [| 'a'; 'e'; 'i'; 'o'; 'u'; 'y'
44
'A'; 'E'; 'I'; 'O'; 'U'; 'Y' |]
55
let s = "The long and winding road..."
6-
printfn $"The first vowel in \n {s}\nis found at position {s.IndexOfAny chars + 1}"
6+
printfn $"The first vowel in \n {s}\nis found at position {s.IndexOfAny chars}"
7+
78
// The example displays the following output:
89
// The first vowel in
910
// The long and winding road...
10-
// is found at position 3
11+
// is found at index 2
1112
// </Snippet1>

snippets/visualbasic/System/String/IndexOfAny/IndexOfAny1.vb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ Option Strict On
44
' <Snippet1>
55
Module Example
66
Public Sub Main()
7-
Dim chars() As Char = { "a"c, "e"c, "i"c, "o"c, "u"c, "y"c,
7+
Dim chars() As Char = { "a"c, "e"c, "i"c, "o"c, "u"c, "y"c,
88
"A"c, "E"c, "I"c, "O"c, "U"c, "Y"c }
99
Dim s As String = "The long and winding road..."
10-
Console.WriteLine("The first vowel in {2} {0}{2}is found at position {1}",
11-
s, s.IndexOfAny(chars) + 1, vbCrLf)
10+
Console.WriteLine("The first vowel in {2} {0}{2}is found at index {1}",
11+
s, s.IndexOfAny(chars), vbCrLf)
1212
End Sub
1313
End Module
14+
1415
' The example displays the following output:
1516
' The first vowel in
1617
' The long and winding road...
17-
' is found at position 3
18+
' is found at index 2
1819
' </Snippet1>

xml/System/String.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7846,13 +7846,15 @@ In the following example, the <see cref="M:System.String.IndexOf(System.String,S
78467846
<format type="text/markdown"><![CDATA[
78477847

78487848
## Remarks
7849+
78497850
Index numbering starts from zero.
78507851

7851-
The search for `anyOf` is case-sensitive. If `anyOf` is an empty array, the method finds a match at the beginning of the string (that is, at index zero).
7852+
The search for `anyOf` is case-sensitive. If `anyOf` is an empty array, the method returns -1.
78527853

78537854
This method performs an ordinal (culture-insensitive) search, where a character is considered equivalent to another character only if their Unicode scalar values are the same. To perform a culture-sensitive search, use the <xref:System.Globalization.CompareInfo.IndexOf%2A?displayProperty=nameWithType> method, where a Unicode scalar value representing a precomposed character, such as the ligature "Æ" (U+00C6), might be considered equivalent to any occurrence of the character's components in the correct sequence, such as "AE" (U+0041, U+0045), depending on the culture.
78547855

78557856
## Examples
7857+
78567858
The following example finds the first vowel in a string.
78577859

78587860
:::code language="csharp" source="~/snippets/csharp/System/String/IndexOfAny/IndexOfAny1.cs" interactive="try-dotnet" id="Snippet1":::

0 commit comments

Comments
 (0)