Skip to content

Commit 57c3ac9

Browse files
authored
move snippet markers on samples for system.string (#970)
Contributes to dotnet/dotnet-api-docs#2539 Some of the samples work if the snippet markers only enclose the body of the Main method.
1 parent 7237c23 commit 57c3ac9

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// <Snippet4>
21
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet4>
88
string s1 = "This string consists of a single short sentence.";
99
int nWords = 0;
1010

@@ -15,10 +15,10 @@ public static void Main()
1515
}
1616
Console.WriteLine("The sentence\n {0}\nhas {1} words.",
1717
s1, nWords);
18+
// The example displays the following output:
19+
// The sentence
20+
// This string consists of a single short sentence.
21+
// has 8 words.
22+
// </Snippet4>
1823
}
1924
}
20-
// The example displays the following output:
21-
// The sentence
22-
// This string consists of a single short sentence.
23-
// has 8 words.
24-
// </Snippet4>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// <Snippet5>
21
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet5>
88
string s1 = "This string consists of a single short sentence.";
99
int nWords = 0;
1010

@@ -15,10 +15,10 @@ public static void Main()
1515
}
1616
Console.WriteLine("The sentence\n {0}\nhas {1} words.",
1717
s1, nWords);
18+
// The example displays the following output:
19+
// The sentence
20+
// This string consists of a single short sentence.
21+
// has 8 words.
22+
// </Snippet5>
1823
}
1924
}
20-
// The example displays the following output:
21-
// The sentence
22-
// This string consists of a single short sentence.
23-
// has 8 words.
24-
// </Snippet5>

snippets/csharp/VS_Snippets_CLR_System/system.String.Class/cs/index3.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// <Snippet6>
21
using System;
32
using System.Collections.Generic;
4-
using System.Globalization;
53

64
public class Example
75
{
86
public static void Main()
97
{
8+
// <Snippet6>
109
// First sentence of The Mystery of the Yellow Room, by Leroux.
1110
string opening = "Ce n'est pas sans une certaine émotion que "+
1211
"je commence à raconter ici les aventures " +
@@ -30,7 +29,8 @@ public static void Main()
3029
}
3130
}
3231

33-
TextElementEnumerator te = StringInfo.GetTextElementEnumerator(opening);
32+
System.Globalization.TextElementEnumerator te =
33+
System.Globalization.StringInfo.GetTextElementEnumerator(opening);
3434
while (te.MoveNext()) {
3535
string s = te.GetTextElement();
3636
// Skip the ' character.
@@ -50,27 +50,27 @@ public static void Main()
5050
for (int ctr = 0; ctr < chars.Count; ctr++)
5151
Console.WriteLine("{0,6} {1,20} {2,20}",
5252
ctr, chars[ctr], elements[ctr]);
53+
// The example displays the following output:
54+
// Word # Char Objects Characters
55+
// 0 2 2
56+
// 1 4 4
57+
// 2 3 3
58+
// 3 4 4
59+
// 4 3 3
60+
// 5 8 8
61+
// 6 8 7
62+
// 7 3 3
63+
// 8 2 2
64+
// 9 8 8
65+
// 10 2 1
66+
// 11 8 8
67+
// 12 3 3
68+
// 13 3 3
69+
// 14 9 9
70+
// 15 15 15
71+
// 16 2 2
72+
// 17 6 6
73+
// 18 12 12
74+
// </Snippet6>
5375
}
5476
}
55-
// The example displays the following output:
56-
// Word # Char Objects Characters
57-
// 0 2 2
58-
// 1 4 4
59-
// 2 3 3
60-
// 3 4 4
61-
// 4 3 3
62-
// 5 8 8
63-
// 6 8 7
64-
// 7 3 3
65-
// 8 2 2
66-
// 9 8 8
67-
// 10 2 1
68-
// 11 8 8
69-
// 12 3 3
70-
// 13 3 3
71-
// 14 9 9
72-
// 15 15 15
73-
// 16 2 2
74-
// 17 6 6
75-
// 18 12 12
76-
// </Snippet6>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
// <Snippet3>
21
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet3>
88
string surrogate = "\uD800\uDC03";
99
for (int ctr = 0; ctr < surrogate.Length; ctr++)
1010
Console.Write("U+{0:X2} ", Convert.ToUInt16(surrogate[ctr]));
1111

1212
Console.WriteLine();
1313
Console.WriteLine(" Is Surrogate Pair: {0}",
1414
Char.IsSurrogatePair(surrogate[0], surrogate[1]));
15+
// The example displays the following output:
16+
// U+D800 U+DC03
17+
// Is Surrogate Pair: True
18+
// </Snippet3>
1519
}
1620
}
17-
// The example displays the following output:
18-
// U+D800 U+DC03
19-
// Is Surrogate Pair: True
20-
// </Snippet3>

0 commit comments

Comments
 (0)