Skip to content

Commit 54e27a3

Browse files
authored
Batches 38-40 - Fix sample output (#6784)
* Fix sample output * one more fix
1 parent 46c6267 commit 54e27a3

File tree

11 files changed

+123
-126
lines changed
  • samples/snippets
    • cpp
      • VS_Snippets_CLR_System
        • system.Attribute.Equals/CPP
        • system.Collection.Specialized.StringDictionary_Enumeration/CPP
      • VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp
    • csharp
    • visualbasic

11 files changed

+123
-126
lines changed

samples/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ int main()
1010
// Regional Info for Sweden
1111
RegionInfo^ ri = gcnew RegionInfo("SE");
1212

13-
Console::Clear();
1413
Console::WriteLine("Region English Name: . . . {0}", ri->EnglishName);
1514
Console::WriteLine("Native Name: . . . . . . . {0}", ri->NativeName);
1615
Console::WriteLine("Currency English Name: . . {0}",

samples/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.Equals/CPP/equals.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public ref class TestClass
5454
public:
5555
// Assign an ArgumentID attribute to each parameter.
5656
// Assign an ArgumentUsage attribute to each parameter.
57-
void TestMethod( [ArgumentID][ArgumentUsage("Must pass an array here.")]array<String^>^strArray,
57+
void TestMethod( [ArgumentID][ArgumentUsage("Must pass an array here.")]array<String^>^strArray,
5858
[ArgumentID][ArgumentUsage("Can pass param list or array here.")]array<String^>^strList ){}
5959
};
6060

6161
int main()
6262
{
63-
// Get the class type, and then get the MethodInfo object
63+
// Get the class type, and then get the MethodInfo object
6464
// for TestMethod to access its metadata.
6565
Type^ clsType = TestClass::typeid;
6666
MethodInfo^ mInfo = clsType->GetMethod( "TestMethod" );
@@ -105,19 +105,19 @@ int main()
105105
}
106106
}
107107
/*
108-
The example displays the following output:
108+
The example displays an output similar to the following:
109109
Compare a usage attribute instance to another instance of the same attribute:
110110
"ArgumentUsageAttribute:Must pass an array here." ==
111111
"ArgumentUsageAttribute:Must pass an array here." ? True
112-
112+
113113
Compare a usage attribute to another usage attribute:
114114
"ArgumentUsageAttribute:Must pass an array here." ==
115115
"ArgumentUsageAttribute:Can pass param list or array here." ? False
116-
116+
117117
Compare an ID attribute instance to another instance of the same attribute:
118118
"ArgumentIDAttribute.22d1a176-4aca-427b-8230-0c1563e13187" ==
119119
"ArgumentIDAttribute.7fa94bba-c290-48e1-a0de-e22f6c1e64f1" ? False
120-
120+
121121
Compare an ID attribute to another ID attribute:
122122
"ArgumentIDAttribute.22d1a176-4aca-427b-8230-0c1563e13187" ==
123123
"ArgumentIDAttribute.b9eea70d-9c0f-459e-a984-19c46b6c8789" ? False

samples/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main()
3131
SamplesStringDictionary::Main();
3232
}
3333
// This code produces the following output.
34-
// VALUE
34+
// VALUES
3535
// verde
3636
// rojo
3737
// azul

samples/snippets/csharp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/CS/rgn5props.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public static void Main()
1111
{
1212
RegionInfo ri = new RegionInfo("SE"); // Sweden
1313

14-
Console.Clear();
1514
Console.WriteLine("Region English Name: . . . {0}", ri.EnglishName);
1615
Console.WriteLine("Native Name: . . . . . . . {0}", ri.NativeName);
1716
Console.WriteLine("Currency English Name: . . {0}", ri.CurrencyEnglishName);

samples/snippets/csharp/VS_Snippets_CLR_System/system.Attribute.Equals/CS/equals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void Main()
126126
}
127127
}
128128
/*
129-
The example displays the following output.
129+
The example displays an output similar to the following:
130130
// Compare a usage attribute instance to another instance of the same attribute:
131131
// "ArgumentUsageAttribute: Must pass an array here." ==
132132
// "ArgumentUsageAttribute: Must pass an array here."? True

samples/snippets/csharp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CS/values.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static void Main()
2323
}
2424
}
2525
// This code produces the following output.
26-
// VALUE
26+
// VALUES
2727
// verde
2828
// rojo
2929
// azul

samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.toint16/cs/toint16_1.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ private static void ConvertChar()
8888
// The example displays the following output:
8989
// 'a' converts to 97.
9090
// 'z' converts to 122.
91-
// '' converts to 7.
92-
// '?' converts to 1023.
93-
// '?' converts to 32767.
94-
// Unable to convert u+FFFE to a UInt16.
91+
// '' converts to 7.
92+
// 'Ͽ' converts to 1023.
93+
// '翿' converts to 32767.
94+
// Unable to convert u+FFFE to an Int16.
9595
// </Snippet3>
9696
}
9797

@@ -298,15 +298,15 @@ private static void ConvertSingle()
298298
}
299299
}
300300
// The example displays the following output:
301-
// -3.40282346638529E+38 is outside the range of the Int16 type.
302-
// -13799999488 is outside the range of the Int16 type.
303-
// Converted the Double value -1023.29901123047 to the Int16 value -1023.
304-
// Converted the Double value -12.9799995422363 to the Int16 value -13.
305-
// Converted the Double value 0 to the Int16 value 0.
306-
// Converted the Double value 9.11299983940444E-16 to the Int16 value 0.
307-
// Converted the Double value 103.918998718262 to the Int16 value 104.
308-
// Converted the Double value 17834.19140625 to the Int16 value 17834.
309-
// 3.40282346638529E+38 is outside the range of the Int16 type.
301+
// -3.4028235E+38 is outside the range of the Int16 type.
302+
// -1.38E+10 is outside the range of the Int16 type.
303+
// Converted the Single value -1023.299 to the Int16 value -1023.
304+
// Converted the Single value -12.98 to the Int16 value -13.
305+
// Converted the Single value 0 to the Int16 value 0.
306+
// Converted the Single value 9.113E-16 to the Int16 value 0.
307+
// Converted the Single value 103.919 to the Int16 value 104.
308+
// Converted the Single value 17834.191 to the Int16 value 17834.
309+
// 3.4028235E+38 is outside the range of the Int16 type.
310310
// </Snippet10>
311311
}
312312

samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple`7.equals/cs/equals2.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ public class RateComparer<T1, T2, T3, T4, T5, T6, T7> : IEqualityComparer
66
{
77
private int argument = 0;
88

9-
public new bool Equals(object x, object y)
9+
public new bool Equals(object x, object y)
1010
{
1111
argument++;
1212
if (argument == 1) return true;
1313

14-
double fx, fy;
14+
double fx, fy;
1515
if (x is Double || x is Single)
1616
{
1717
fx = (double) x;
@@ -23,42 +23,42 @@ public class RateComparer<T1, T2, T3, T4, T5, T6, T7> : IEqualityComparer
2323
return x.Equals(y);
2424
}
2525
}
26-
26+
2727
public int GetHashCode(object obj)
2828
{
2929
if (obj is Single || obj is Double)
3030
return Math.Round(((double) obj) * 1000).GetHashCode();
3131
else
3232
return obj.GetHashCode();
33-
}
33+
}
3434
}
3535

3636
public class Example
3737
{
3838
public static void Main()
3939
{
40-
var rate1 = Tuple.Create("New York", -.013934, .014505,
40+
var rate1 = Tuple.Create("New York", -.013934, .014505,
4141
-.1042733, .0354833, .093644, .0290792);
42-
var rate2 = Tuple.Create("Unknown City", -.013934, .014505,
42+
var rate2 = Tuple.Create("Unknown City", -.013934, .014505,
4343
-.1042733, .0354833, .093644, .0290792);
44-
var rate3 = Tuple.Create("Unknown City", -.013934, .014505,
44+
var rate3 = Tuple.Create("Unknown City", -.013934, .014505,
4545
-.1042733, .0354833, .093644, .029079);
46-
var rate4 = Tuple.Create("San Francisco", -.0451934, -.0332858,
46+
var rate4 = Tuple.Create("San Francisco", -.0451934, -.0332858,
4747
-.0512803, .0662544, .0728964, .0491912);
4848
IStructuralEquatable eq = rate1;
4949
// Compare first tuple with remaining two tuples.
5050
Console.WriteLine("{0} = ", rate1.ToString());
51-
Console.WriteLine(" {0} : {1}", rate2,
51+
Console.WriteLine(" {0} : {1}", rate2,
5252
eq.Equals(rate2, new RateComparer<string, double, double, double, double, double, double>()));
53-
Console.WriteLine(" {0} : {1}", rate3,
53+
Console.WriteLine(" {0} : {1}", rate3,
5454
eq.Equals(rate3, new RateComparer<string, double, double, double, double, double, double>()));
55-
Console.WriteLine(" {0} : {1}", rate4,
55+
Console.WriteLine(" {0} : {1}", rate4,
5656
eq.Equals(rate4, new RateComparer<string, double, double,double, double, double, double>()));
5757
}
5858
}
5959
// The example displays the following output:
60-
// (New York, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) =
61-
// (Unknown City, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) : True
62-
// (Unknown City, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.029079) : True
63-
// (San Francisco, -0.0332858, -0.0512803, 0.0662544, 0.0728964, 0.0491912) : False
60+
// (New York, -0.013934, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) =
61+
// (Unknown City, -0.013934, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) : True
62+
// (Unknown City, -0.013934, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.029079) : True
63+
// (San Francisco, -0.0451934, -0.0332858, -0.0512803, 0.0662544, 0.0728964, 0.0491912) : False
6464
// </Snippet2>

samples/snippets/visualbasic/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/VB/rgn5props.vb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
'<snippet1>
2-
' This example demonstrates the RegionInfo.EnglishName, NativeName,
2+
' This example demonstrates the RegionInfo.EnglishName, NativeName,
33
' CurrencyEnglishName, CurrencyNativeName, and GeoId properties.
44
Imports System.Globalization
55

66
Class Sample
77
Public Shared Sub Main()
88
Dim ri As New RegionInfo("SE") ' Sweden
9-
Console.Clear()
109
Console.WriteLine("Region English Name: . . . {0}", ri.EnglishName)
1110
Console.WriteLine("Native Name: . . . . . . . {0}", ri.NativeName)
1211
Console.WriteLine("Currency English Name: . . {0}", ri.CurrencyEnglishName)

samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.Equals/VB/equals.vb

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,128 +3,128 @@
33
' Define a custom parameter attribute that takes a single message argument.
44
<AttributeUsage(AttributeTargets.Parameter)> _
55
Public Class ArgumentUsageAttribute : Inherits Attribute
6-
6+
77
' This is the attribute constructor.
88
Public Sub New(UsageMsg As String)
99
Me.usageMsg = UsageMsg
10-
End Sub
10+
End Sub
1111

1212
' usageMsg is storage for the attribute message.
1313
Protected usageMsg As String
14-
14+
1515
' Append the message to what the base generates.
1616
Public Overrides Function ToString() As String
1717
Return $"{MyBase.ToString()}: {usageMsg}"
18-
End Function
19-
End Class
18+
End Function
19+
End Class
2020

2121
' Define a custom parameter attribute that generates a GUID for each instance.
2222
<AttributeUsage(AttributeTargets.Parameter)> _
2323
Public Class ArgumentIDAttribute : Inherits Attribute
24-
24+
2525
' This is the attribute constructor, which generates the GUID.
2626
Public Sub New()
2727
Me.GUIDinstance = Guid.NewGuid()
2828
End Sub
2929

3030
' instanceGUID is storage for the generated GUID.
3131
Protected GUIDinstance As Guid
32-
32+
3333
' Append the GUID to what the base generates.
3434
Public Overrides Function ToString() As String
3535
Return $"{MyBase.ToString()}.{ GUIDinstance}"
36-
End Function
36+
End Function
3737
End Class
3838

3939
Public Class TestClass
4040
' Assign an ArgumentID and an ArgumentUsage attribute to each parameter.
41-
Public Sub TestMethod(
42-
<ArgumentID, ArgumentUsage("Must pass an array here.")>
43-
strArray() As String,
44-
<ArgumentID, ArgumentUsage("Can pass param list or array here.")>
41+
Public Sub TestMethod(
42+
<ArgumentID, ArgumentUsage("Must pass an array here.")>
43+
strArray() As String,
44+
<ArgumentID, ArgumentUsage("Can pass param list or array here.")>
4545
ParamArray strList() As String)
4646
End Sub
47-
End Class
48-
47+
End Class
48+
4949
Module AttributeEqualsDemo
5050
Sub Main()
51-
' Get the class type.
51+
' Get the class type.
5252
Dim clsType As Type = GetType(TestClass)
53-
' Get the MethodInfo object for TestMethod to access its metadata.
53+
' Get the MethodInfo object for TestMethod to access its metadata.
5454
Dim mInfo As MethodInfo = clsType.GetMethod("TestMethod")
55-
55+
5656
' There will be two elements in pInfoArray, one for each parameter.
5757
Dim pInfoArray As ParameterInfo() = mInfo.GetParameters()
5858
If pInfoArray IsNot Nothing Then
5959
' Create an instance of the argument usage attribute on strArray.
60-
Dim arrayUsageAttr1 As ArgumentUsageAttribute =
61-
Attribute.GetCustomAttribute(pInfoArray(0),
60+
Dim arrayUsageAttr1 As ArgumentUsageAttribute =
61+
Attribute.GetCustomAttribute(pInfoArray(0),
6262
GetType(ArgumentUsageAttribute))
63-
63+
6464
' Create another instance of the argument usage attribute on strArray.
6565
Dim arrayUsageAttr2 As ArgumentUsageAttribute = _
6666
Attribute.GetCustomAttribute(pInfoArray(0), _
6767
GetType(ArgumentUsageAttribute))
68-
68+
6969
' Create an instance of the argument usage attribute on strList.
7070
Dim listUsageAttr As ArgumentUsageAttribute = _
7171
Attribute.GetCustomAttribute(pInfoArray(1), _
7272
GetType(ArgumentUsageAttribute))
73-
73+
7474
' Create an instance of the argument ID attribute on strArray.
7575
Dim arrayIDAttr1 As ArgumentIDAttribute = _
7676
Attribute.GetCustomAttribute(pInfoArray(0), _
7777
GetType(ArgumentIDAttribute))
78-
78+
7979
' Create another instance of the argument ID attribute on strArray.
8080
Dim arrayIDAttr2 As ArgumentIDAttribute = _
8181
Attribute.GetCustomAttribute(pInfoArray(0), _
8282
GetType(ArgumentIDAttribute))
83-
83+
8484
' Create an instance of the argument ID attribute on strList.
8585
Dim listIDAttr As ArgumentIDAttribute = _
8686
Attribute.GetCustomAttribute(pInfoArray(1), _
8787
GetType(ArgumentIDAttribute))
88-
88+
8989
' Compare various pairs of attributes for equality.
9090
Console.WriteLine(vbCrLf & "Compare a usage attribute instance " & _
9191
"to another instance of the same attribute:")
92-
Console.WriteLine($" ""{arrayUsageAttr1}"" = {vbCrLf}" +
93-
$" ""{arrayUsageAttr2}""? {arrayUsageAttr1.Equals(arrayUsageAttr2)}")
94-
92+
Console.WriteLine($" ""{arrayUsageAttr1}"" = {vbCrLf}" +
93+
$" ""{arrayUsageAttr2}""? {arrayUsageAttr1.Equals(arrayUsageAttr2)}")
94+
9595
Console.WriteLine(vbCrLf & _
9696
"Compare a usage attribute to another usage attribute:")
97-
Console.WriteLine($" ""{arrayUsageAttr1}"" = {vbCrLf}" +
98-
$" ""{listUsageAttr}""? {arrayUsageAttr1.Equals(listUsageAttr)}")
99-
97+
Console.WriteLine($" ""{arrayUsageAttr1}"" = {vbCrLf}" +
98+
$" ""{listUsageAttr}""? {arrayUsageAttr1.Equals(listUsageAttr)}")
99+
100100
Console.WriteLine(vbCrLf & "Compare an ID attribute instance " & _
101101
"to another instance of the same attribute:")
102102
Console.WriteLine($" ""{arrayIDAttr1}"" = {vbCrLf}" +
103103
$" ""{arrayIDAttr2}""? {arrayIDAttr1.Equals(arrayIDAttr2)}")
104-
104+
105105
Console.WriteLine(vbCrLf & _
106106
"Compare an ID attribute to another ID attribute:")
107-
Console.WriteLine($" ""{arrayIDAttr1}"" ={vbCrLf}" +
107+
Console.WriteLine($" ""{arrayIDAttr1}"" ={vbCrLf}" +
108108
$" ""{listIDAttr}"" ? {arrayIDAttr1.Equals(listIDAttr)}")
109109
Else
110110
Console.WriteLine("The parameters information could " & _
111111
"not be retrieved for method {0}.", mInfo.Name)
112112
End If
113-
End Sub
114-
End Module
115-
' The example displays the following output.
113+
End Sub
114+
End Module
115+
' The example displays an output similar to the following:
116116
' Compare a usage attribute instance to another instance of the same attribute:
117117
' "ArgumentUsageAttribute: Must pass an array here." =
118118
' "ArgumentUsageAttribute: Must pass an array here."? True
119-
'
119+
'
120120
' Compare a usage attribute to another usage attribute:
121121
' "ArgumentUsageAttribute: Must pass an array here." =
122122
' "ArgumentUsageAttribute: Can pass param list or array here."? False
123-
'
123+
'
124124
' Compare an ID attribute instance to another instance of the same attribute:
125125
' "ArgumentIDAttribute.d4f78468-f1d0-4a08-b6da-58cad249f8ea" =
126126
' "ArgumentIDAttribute.9b1151bd-9c87-4e9f-beb0-92375f8c24f7"? False
127-
'
127+
'
128128
' Compare an ID attribute to another ID attribute:
129129
' "ArgumentIDAttribute.d4f78468-f1d0-4a08-b6da-58cad249f8ea" =
130130
' "ArgumentIDAttribute.7eba47d0-ff29-4e46-9740-e0ba05b39947"? False

0 commit comments

Comments
 (0)