Skip to content

Commit be11327

Browse files
WilliamAntonRohmmairaw
authored andcommitted
Object.xml -- updating samples for Try .NET (#1640)
* updating for Try .NET * reverting per review
1 parent e97efcb commit be11327

File tree

8 files changed

+61
-65
lines changed

8 files changed

+61
-65
lines changed
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// <Snippet1>
2-
using System;
1+
using System;
32

43
class MyClass {
54

65
static void Main() {
6+
// <Snippet1>
77
object o = null;
88
object p = null;
99
object q = new Object();
@@ -12,18 +12,11 @@ static void Main() {
1212
p = q;
1313
Console.WriteLine(Object.ReferenceEquals(p, q));
1414
Console.WriteLine(Object.ReferenceEquals(o, p));
15+
16+
// This code produces the following output:
17+
// True
18+
// True
19+
// False
20+
// </Snippet1>
1521
}
1622
}
17-
18-
19-
/*
20-
21-
This code produces the following output.
22-
23-
True
24-
True
25-
False
26-
27-
*/
28-
// </Snippet1>
29-

snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_val1.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// <Snippet3>
2-
using System;
1+
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet3>
88
byte value1 = 12;
99
int value2 = 12;
1010

@@ -15,8 +15,9 @@ public static void Main()
1515
object1, object1.GetType().Name,
1616
object2, object2.GetType().Name,
1717
object1.Equals(object2));
18+
19+
// The example displays the following output:
20+
// 12 (Byte) = 12 (Int32): False
21+
// </Snippet3>
1822
}
1923
}
20-
// The example displays the following output:
21-
// 12 (Byte) = 12 (Int32): False
22-
// </Snippet3>
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// <Snippet2>
2-
using System;
1+
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet2>
88
object[] values = { (int) 12, (long) 10653, (byte) 12, (sbyte) -5,
99
16.3, "string" };
1010
foreach (var value in values) {
@@ -23,17 +23,14 @@ public static void Main()
2323
else
2424
Console.WriteLine("'{0}' is another data type.", value);
2525
}
26+
27+
// The example displays the following output:
28+
// 12 is a 32-bit integer.
29+
// 10653 is a 32-bit integer.
30+
// 12 is an unsigned byte.
31+
// -5 is a signed byte.
32+
// 16.3 is a double-precision floating point.
33+
// 'string' is another data type.
34+
// </Snippet2>
2635
}
2736
}
28-
// The example displays the following output:
29-
// 12 is a 32-bit integer.
30-
// 10653 is a 32-bit integer.
31-
// 12 is an unsigned byte.
32-
// -5 is a signed byte.
33-
// 16.3 is a double-precision floating point.
34-
// 'string' is another data type.
35-
// </Snippet2>
36-
37-
38-
39-

snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs

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

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet1>
88
int n1 = 12;
99
int n2 = 82;
1010
long n3 = 12;
@@ -13,9 +13,10 @@ public static void Main()
1313
Object.ReferenceEquals(n1.GetType(), n2.GetType()));
1414
Console.WriteLine("n1 and n3 are the same type: {0}",
1515
Object.ReferenceEquals(n1.GetType(), n3.GetType()));
16+
17+
// The example displays the following output:
18+
// n1 and n2 are the same type: True
19+
// n1 and n3 are the same type: False
20+
// </Snippet1>
1621
}
1722
}
18-
// The example displays the following output:
19-
// n1 and n2 are the same type: True
20-
// n1 and n3 are the same type: False
21-
// </Snippet1>

snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequals4.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
// <Snippet1>
2-
using System;
1+
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet1>
88
int int1 = 3;
99
Console.WriteLine(Object.ReferenceEquals(int1, int1));
1010
Console.WriteLine(int1.GetType().IsValueType);
11+
12+
// The example displays the following output:
13+
// False
14+
// True
15+
// </Snippet1>
1116
}
1217
}
13-
// The example displays the following output:
14-
// False
15-
// True
16-
// </Snippet1>

snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequalsa.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// <Snippet2>
2-
using System;
1+
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet2>
88
String s1 = "String1";
99
String s2 = "String1";
1010
Console.WriteLine("s1 = s2: {0}", Object.ReferenceEquals(s1, s2));
@@ -17,11 +17,12 @@ public static void Main()
1717
Console.WriteLine("s3 = s4: {0}", Object.ReferenceEquals(s3, s4));
1818
Console.WriteLine("{0} interned: {1}", s3,
1919
String.IsNullOrEmpty(String.IsInterned(s3)) ? "No" : "Yes");
20+
21+
// The example displays the following output:
22+
// s1 = s2: True
23+
// String1 interned: Yes
24+
// s3 = s4: False
25+
// StringA interned: No
26+
// </Snippet2>
2027
}
2128
}
22-
// The example displays the following output:
23-
// s1 = s2: True
24-
// String1 interned: Yes
25-
// s3 = s4: False
26-
// StringA interned: No
27-
// </Snippet2>

snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/array1.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
// <Snippet6>
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43

54
public class Example
65
{
76
public static void Main()
87
{
8+
// <Snippet6>
99
int[] values = { 1, 2, 4, 8, 16, 32, 64, 128 };
1010
Console.WriteLine(values.ToString());
1111

1212
List<int> list = new List<int>(values);
1313
Console.WriteLine(list.ToString());
14+
15+
// The example displays the following output:
16+
// System.Int32[]
17+
// System.Collections.Generic.List`1[System.Int32]
18+
// </Snippet6>
1419
}
1520
}
16-
// The example displays the following output:
17-
// System.Int32[]
18-
// System.Collections.Generic.List`1[System.Int32]
19-
// </Snippet6>

snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostring1.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
// <Snippet1>
2-
using System;
1+
using System;
32

43
public class Example
54
{
65
public static void Main()
76
{
7+
// <Snippet1>
88
Object obj = new Object();
99
Console.WriteLine(obj.ToString());
10+
11+
// The example displays the following output:
12+
// System.Object
13+
// </Snippet1>
1014
}
1115
}
12-
// The example displays the following output:
13-
// System.Object
14-
// </Snippet1>

0 commit comments

Comments
 (0)