Skip to content

Commit 2b9cfbe

Browse files
committed
add missing project files
1 parent 4111d49 commit 2b9cfbe

File tree

9 files changed

+126
-79
lines changed

9 files changed

+126
-79
lines changed

snippets/csharp/System/String/IndexOfAny/IndexOfAny1.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using System;
22

3-
public class Example
3+
public class Example1
44
{
5-
public static void Main()
5+
public static void Run()
66
{
77
// <Snippet1>
88
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 {s}\nis found at index {s.IndexOfAny(chars)}");
11+
Console.WriteLine($"The first vowel in \n {s}\n" +
12+
$"is found at index {s.IndexOfAny(chars)}");
1213

1314
// The example displays the following output:
1415
// The first vowel in
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Project
8+
{
9+
internal class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
Example1.Run();
14+
Example2.Run();
15+
Example3.Run();
16+
}
17+
}
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>
Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
1-
//<snippet1>
1+

22
// Sample for String.IndexOfAny(Char[], Int32)
33
using System;
44

5-
class Sample {
6-
public static void Main()
5+
class Example2
6+
{
7+
public static void Run()
78
{
8-
string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-";
9-
string br2 = "0123456789012345678901234567890123456789012345678901234567890123456";
10-
string str = "Now is the time for all good men to come to the aid of their party.";
11-
int start;
12-
int at;
13-
string target = "is";
14-
char[] anyOf = target.ToCharArray();
9+
//<snippet1>
10+
string br1 = "0----+----1----+----2----+----3" +
11+
"----+----4----+----5----+----6----+-";
12+
string br2 = "012345678901234567890123456789" +
13+
"0123456789012345678901234567890123456";
14+
string str = "Now is the time for all good men " +
15+
"to come to the aid of their party.";
16+
int start;
17+
int at;
18+
string target = "is";
19+
char[] anyOf = target.ToCharArray();
1520

16-
start = str.Length/2;
17-
Console.WriteLine();
18-
Console.WriteLine("The first character occurrence from position {0} to {1}.",
19-
start, str.Length-1);
20-
Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str);
21-
Console.Write("A character in '{0}' occurs at position: ", target);
21+
start = str.Length / 2;
22+
Console.WriteLine();
23+
Console.WriteLine("The first character occurrence " +
24+
$"from position {start} to {str.Length - 1}:");
25+
Console.WriteLine($"{Environment.NewLine}{br1}{Environment.NewLine}" +
26+
$"{br2}{Environment.NewLine}{str}{Environment.NewLine}");
27+
Console.Write($"A character in '{target}' occurs at position: ");
2228

23-
at = str.IndexOfAny(anyOf, start);
24-
if (at > -1)
25-
Console.Write(at);
26-
else
27-
Console.Write("(not found)");
28-
Console.WriteLine();
29-
}
30-
}
31-
/*
29+
at = str.IndexOfAny(anyOf, start);
30+
if (at > -1)
31+
Console.Write(at);
32+
else
33+
Console.Write("(not found)");
34+
Console.WriteLine();
35+
36+
/*
3237
33-
The first character occurrence from position 33 to 66.
34-
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
35-
0123456789012345678901234567890123456789012345678901234567890123456
36-
Now is the time for all good men to come to the aid of their party.
38+
The first character occurrence from position 33 to 66.
39+
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
40+
0123456789012345678901234567890123456789012345678901234567890123456
41+
Now is the time for all good men to come to the aid of their party.
3742
38-
A character in 'is' occurs at position: 49
43+
A character in 'is' occurs at position: 49
3944
40-
*/
41-
//</snippet1>
45+
*/
46+
//</snippet1>
47+
}
48+
}
Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
1-
//<snippet1>
1+

22
// Sample for String.IndexOfAny(Char[], Int32, Int32)
33
using System;
44

5-
class Sample {
6-
public static void Main()
5+
class Example3
6+
{
7+
public static void Run()
78
{
8-
string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-";
9-
string br2 = "0123456789012345678901234567890123456789012345678901234567890123456";
10-
string str = "Now is the time for all good men to come to the aid of their party.";
11-
int start;
12-
int at;
13-
int count;
14-
string target = "aid";
15-
char[] anyOf = target.ToCharArray();
9+
//<snippet1>
10+
string br1 = "0----+----1----+----2----+----3----" +
11+
"+----4----+----5----+----6----+-";
12+
string br2 = "012345678901234567890123456789" +
13+
"0123456789012345678901234567890123456";
14+
string str = "Now is the time for all good men " +
15+
"to come to the aid of their party.";
16+
string target = "aid";
17+
char[] anyOf = target.ToCharArray();
1618

17-
start = (str.Length-1)/3;
18-
count = (str.Length-1)/4;
19-
Console.WriteLine();
20-
Console.WriteLine("The first character occurrence from position {0} for {1} characters.", start, count);
21-
Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str);
22-
Console.Write("A character in '{0}' occurs at position: ", target);
19+
int start = (str.Length - 1) / 3;
20+
int count = (str.Length - 1) / 4;
21+
Console.WriteLine();
22+
Console.WriteLine("The first character occurrence from " +
23+
$"position {start} for {count} characters:");
24+
Console.WriteLine($"{Environment.NewLine}{br1}{Environment.NewLine}{br2}" +
25+
$"{Environment.NewLine}{str}{Environment.NewLine}");
26+
Console.Write($"A character in '{target}' occurs at position: ");
2327

24-
at = str.IndexOfAny(anyOf, start, count);
25-
if (at > -1)
26-
Console.Write(at);
27-
else
28-
Console.Write("(not found)");
29-
Console.WriteLine();
30-
}
31-
}
32-
/*
28+
int at = str.IndexOfAny(anyOf, start, count);
29+
if (at > -1)
30+
Console.Write(at);
31+
else
32+
Console.Write("(not found)");
33+
Console.WriteLine();
34+
35+
/*
3336
34-
The first character occurrence from position 22 for 16 characters.
35-
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
36-
0123456789012345678901234567890123456789012345678901234567890123456
37-
Now is the time for all good men to come to the aid of their party.
37+
The first character occurrence from position 22 for 16 characters.
38+
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
39+
0123456789012345678901234567890123456789012345678901234567890123456
40+
Now is the time for all good men to come to the aid of their party.
3841
39-
A character in 'aid' occurs at position: 27
42+
A character in 'aid' occurs at position: 27
4043
41-
*/
42-
//</snippet1>
44+
*/
45+
//</snippet1>
46+
}
47+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Option Strict On
33

44
' <Snippet1>
5-
Module Example
6-
Public Sub Main()
5+
Module Example1
6+
Public Sub Run()
77
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..."
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'<snippet1>
22
' Sample for String.IndexOfAny(Char[], Int32)
3-
Class Sample
4-
Public Shared Sub Main()
3+
Class Example2
4+
Public Shared Sub Run()
55
Dim br1 As String = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"
66
Dim br2 As String = "0123456789012345678901234567890123456789012345678901234567890123456"
77
Dim str As String = "Now is the time for all good men to come to the aid of their party."
88
Dim start As Integer
99
Dim at As Integer
1010
Dim target As String = "is"
1111
Dim anyOf As Char() = target.ToCharArray()
12-
12+
1313
start = str.Length / 2
1414
Console.WriteLine()
1515
Console.WriteLine("Search for a character occurrence from position {0} to {1}.", _
@@ -34,4 +34,4 @@ End Class
3434
'
3535
'A character in 'is' occurs at position: 49
3636
'
37-
'</snippet1>
37+
'</snippet1>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'<snippet1>
22
' Sample for String.IndexOfAny(Char[], Int32, Int32)
3-
Class Sample
4-
Public Shared Sub Main()
3+
Class Example3
4+
Public Shared Sub Run()
55
Dim br1 As String = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"
66
Dim br2 As String = "0123456789012345678901234567890123456789012345678901234567890123456"
77
Dim str As String = "Now is the time for all good men to come to the aid of their party."
@@ -10,14 +10,14 @@ Class Sample
1010
Dim count As Integer
1111
Dim target As String = "aid"
1212
Dim anyOf As Char() = target.ToCharArray()
13-
13+
1414
start =(str.Length - 1) / 3
1515
count =(str.Length - 1) / 4
1616
Console.WriteLine()
1717
Console.WriteLine("The first character occurrence from position {0} for {1} characters.", start, count)
1818
Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str)
1919
Console.Write("A character in '{0}' occurs at position: ", target)
20-
20+
2121
at = str.IndexOfAny(anyOf, start, count)
2222
If at > - 1 Then
2323
Console.Write(at)
@@ -35,4 +35,4 @@ End Class
3535
'
3636
'A character in 'aid' occurs at position: 27
3737
'
38-
'</snippet1>
38+
'</snippet1>

0 commit comments

Comments
 (0)