-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix remark about empty array #11625
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
Fix remark about empty array #11625
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
// <Snippet1> | ||
using System; | ||
using System; | ||
|
||
public class Example | ||
public class Example1 | ||
{ | ||
public static void Main() | ||
public static void Run() | ||
{ | ||
char[] chars = { 'a', 'e', 'i', 'o', 'u', 'y', | ||
// <Snippet1> | ||
char[] chars = { 'a', 'e', 'i', 'o', 'u', 'y', | ||
'A', 'E', 'I', 'O', 'U', 'Y' }; | ||
String s = "The long and winding road..."; | ||
Console.WriteLine("The first vowel in \n {0}\nis found at position {1}", | ||
s, s.IndexOfAny(chars) + 1); | ||
Console.WriteLine($"The first vowel in \n {s}\n" + | ||
$"is found at index {s.IndexOfAny(chars)}"); | ||
|
||
// The example displays the following output: | ||
// The first vowel in | ||
// The long and winding road... | ||
// is found at index 2 | ||
// </Snippet1> | ||
} | ||
} | ||
// The example displays the following output: | ||
// The first vowel in | ||
// The long and winding road... | ||
// is found at position 3 | ||
// </Snippet1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Project | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Example1.Run(); | ||
Example2.Run(); | ||
Example3.Run(); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,48 @@ | ||
//<snippet1> | ||
| ||
// Sample for String.IndexOfAny(Char[], Int32) | ||
using System; | ||
|
||
class Sample { | ||
public static void Main() | ||
class Example2 | ||
{ | ||
public static void Run() | ||
{ | ||
string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; | ||
string br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; | ||
string str = "Now is the time for all good men to come to the aid of their party."; | ||
int start; | ||
int at; | ||
string target = "is"; | ||
char[] anyOf = target.ToCharArray(); | ||
//<snippet1> | ||
string br1 = "0----+----1----+----2----+----3" + | ||
"----+----4----+----5----+----6----+-"; | ||
string br2 = "012345678901234567890123456789" + | ||
"0123456789012345678901234567890123456"; | ||
string str = "Now is the time for all good men " + | ||
"to come to the aid of their party."; | ||
int start; | ||
int at; | ||
string target = "is"; | ||
char[] anyOf = target.ToCharArray(); | ||
|
||
start = str.Length/2; | ||
Console.WriteLine(); | ||
Console.WriteLine("The first character occurrence from position {0} to {1}.", | ||
start, str.Length-1); | ||
Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str); | ||
Console.Write("A character in '{0}' occurs at position: ", target); | ||
start = str.Length / 2; | ||
Console.WriteLine(); | ||
Console.WriteLine("The first character occurrence " + | ||
$"from position {start} to {str.Length - 1}:"); | ||
Console.WriteLine($"{Environment.NewLine}{br1}{Environment.NewLine}" + | ||
$"{br2}{Environment.NewLine}{str}{Environment.NewLine}"); | ||
Console.Write($"A character in '{target}' occurs at position: "); | ||
gewarren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
at = str.IndexOfAny(anyOf, start); | ||
if (at > -1) | ||
Console.Write(at); | ||
else | ||
Console.Write("(not found)"); | ||
Console.WriteLine(); | ||
} | ||
} | ||
/* | ||
at = str.IndexOfAny(anyOf, start); | ||
if (at > -1) | ||
Console.Write(at); | ||
else | ||
Console.Write("(not found)"); | ||
Console.WriteLine(); | ||
|
||
/* | ||
|
||
The first character occurrence from position 33 to 66. | ||
0----+----1----+----2----+----3----+----4----+----5----+----6----+- | ||
0123456789012345678901234567890123456789012345678901234567890123456 | ||
Now is the time for all good men to come to the aid of their party. | ||
The first character occurrence from position 33 to 66. | ||
0----+----1----+----2----+----3----+----4----+----5----+----6----+- | ||
0123456789012345678901234567890123456789012345678901234567890123456 | ||
Now is the time for all good men to come to the aid of their party. | ||
|
||
A character in 'is' occurs at position: 49 | ||
A character in 'is' occurs at position: 49 | ||
|
||
*/ | ||
//</snippet1> | ||
*/ | ||
//</snippet1> | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,47 @@ | ||
//<snippet1> | ||
| ||
// Sample for String.IndexOfAny(Char[], Int32, Int32) | ||
using System; | ||
|
||
class Sample { | ||
public static void Main() | ||
class Example3 | ||
{ | ||
public static void Run() | ||
{ | ||
string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; | ||
string br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; | ||
string str = "Now is the time for all good men to come to the aid of their party."; | ||
int start; | ||
int at; | ||
int count; | ||
string target = "aid"; | ||
char[] anyOf = target.ToCharArray(); | ||
//<snippet1> | ||
string br1 = "0----+----1----+----2----+----3----" + | ||
"+----4----+----5----+----6----+-"; | ||
string br2 = "012345678901234567890123456789" + | ||
"0123456789012345678901234567890123456"; | ||
string str = "Now is the time for all good men " + | ||
"to come to the aid of their party."; | ||
string target = "aid"; | ||
char[] anyOf = target.ToCharArray(); | ||
|
||
start = (str.Length-1)/3; | ||
count = (str.Length-1)/4; | ||
Console.WriteLine(); | ||
Console.WriteLine("The first character occurrence from position {0} for {1} characters.", start, count); | ||
Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str); | ||
Console.Write("A character in '{0}' occurs at position: ", target); | ||
int start = (str.Length - 1) / 3; | ||
int count = (str.Length - 1) / 4; | ||
Console.WriteLine(); | ||
Console.WriteLine("The first character occurrence from " + | ||
$"position {start} for {count} characters:"); | ||
Console.WriteLine($"{Environment.NewLine}{br1}{Environment.NewLine}{br2}" + | ||
$"{Environment.NewLine}{str}{Environment.NewLine}"); | ||
Console.Write($"A character in '{target}' occurs at position: "); | ||
|
||
at = str.IndexOfAny(anyOf, start, count); | ||
if (at > -1) | ||
Console.Write(at); | ||
else | ||
Console.Write("(not found)"); | ||
Console.WriteLine(); | ||
} | ||
} | ||
/* | ||
int at = str.IndexOfAny(anyOf, start, count); | ||
if (at > -1) | ||
Console.Write(at); | ||
else | ||
Console.Write("(not found)"); | ||
Console.WriteLine(); | ||
|
||
/* | ||
|
||
The first character occurrence from position 22 for 16 characters. | ||
0----+----1----+----2----+----3----+----4----+----5----+----6----+- | ||
0123456789012345678901234567890123456789012345678901234567890123456 | ||
Now is the time for all good men to come to the aid of their party. | ||
The first character occurrence from position 22 for 16 characters. | ||
0----+----1----+----2----+----3----+----4----+----5----+----6----+- | ||
0123456789012345678901234567890123456789012345678901234567890123456 | ||
Now is the time for all good men to come to the aid of their party. | ||
|
||
A character in 'aid' occurs at position: 27 | ||
A character in 'aid' occurs at position: 27 | ||
|
||
*/ | ||
//</snippet1> | ||
*/ | ||
//</snippet1> | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.