Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// <Snippet1>
using System;
using System;

class MyClass {

static void Main() {
// <Snippet1>
object o = null;
object p = null;
object q = new Object();
Expand All @@ -12,18 +12,11 @@ static void Main() {
p = q;
Console.WriteLine(Object.ReferenceEquals(p, q));
Console.WriteLine(Object.ReferenceEquals(o, p));

// This code produces the following output:
// True
// True
// False
// </Snippet1>
}
}


/*

This code produces the following output.

True
True
False

*/
// </Snippet1>

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// <Snippet3>
using System;
using System;

public class Example
{
public static void Main()
{
// <Snippet3>
byte value1 = 12;
int value2 = 12;

Expand All @@ -15,8 +15,9 @@ public static void Main()
object1, object1.GetType().Name,
object2, object2.GetType().Name,
object1.Equals(object2));

// The example displays the following output:
// 12 (Byte) = 12 (Int32): False
// </Snippet3>
}
}
// The example displays the following output:
// 12 (Byte) = 12 (Int32): False
// </Snippet3>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// <Snippet2>
using System;
using System;

public class Example
{
public static void Main()
{
// <Snippet2>
object[] values = { (int) 12, (long) 10653, (byte) 12, (sbyte) -5,
16.3, "string" };
foreach (var value in values) {
Expand All @@ -23,17 +23,14 @@ public static void Main()
else
Console.WriteLine("'{0}' is another data type.", value);
}

// The example displays the following output:
// 12 is a 32-bit integer.
// 10653 is a 32-bit integer.
// 12 is an unsigned byte.
// -5 is a signed byte.
// 16.3 is a double-precision floating point.
// 'string' is another data type.
// </Snippet2>
}
}
// The example displays the following output:
// 12 is a 32-bit integer.
// 10653 is a 32-bit integer.
// 12 is an unsigned byte.
// -5 is a signed byte.
// 16.3 is a double-precision floating point.
// 'string' is another data type.
// </Snippet2>




Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// <Snippet1>
using System;
using System;

public class Example
{
public static void Main()
{
// <Snippet1>
int n1 = 12;
int n2 = 82;
long n3 = 12;
Expand All @@ -13,9 +13,10 @@ public static void Main()
Object.ReferenceEquals(n1.GetType(), n2.GetType()));
Console.WriteLine("n1 and n3 are the same type: {0}",
Object.ReferenceEquals(n1.GetType(), n3.GetType()));

// The example displays the following output:
// n1 and n2 are the same type: True
// n1 and n3 are the same type: False
// </Snippet1>
}
}
// The example displays the following output:
// n1 and n2 are the same type: True
// n1 and n3 are the same type: False
// </Snippet1>
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// <Snippet1>
using System;
using System;

public class Example
{
public static void Main()
{
// <Snippet1>
int int1 = 3;
Console.WriteLine(Object.ReferenceEquals(int1, int1));
Console.WriteLine(int1.GetType().IsValueType);

// The example displays the following output:
// False
// True
// </Snippet1>
}
}
// The example displays the following output:
// False
// True
// </Snippet1>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// <Snippet2>
using System;
using System;

public class Example
{
public static void Main()
{
// <Snippet2>
String s1 = "String1";
String s2 = "String1";
Console.WriteLine("s1 = s2: {0}", Object.ReferenceEquals(s1, s2));
Expand All @@ -17,11 +17,12 @@ public static void Main()
Console.WriteLine("s3 = s4: {0}", Object.ReferenceEquals(s3, s4));
Console.WriteLine("{0} interned: {1}", s3,
String.IsNullOrEmpty(String.IsInterned(s3)) ? "No" : "Yes");

// The example displays the following output:
// s1 = s2: True
// String1 interned: Yes
// s3 = s4: False
// StringA interned: No
// </Snippet2>
}
}
// The example displays the following output:
// s1 = s2: True
// String1 interned: Yes
// s3 = s4: False
// StringA interned: No
// </Snippet2>
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// <Snippet6>
using System;
using System;
using System.Collections.Generic;

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

List<int> list = new List<int>(values);
Console.WriteLine(list.ToString());

// The example displays the following output:
// System.Int32[]
// System.Collections.Generic.List`1[System.Int32]
// </Snippet6>
}
}
// The example displays the following output:
// System.Int32[]
// System.Collections.Generic.List`1[System.Int32]
// </Snippet6>
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// <Snippet1>
using System;
using System;

public class Example
{
public static void Main()
{
// <Snippet1>
Object obj = new Object();
Console.WriteLine(obj.ToString());

// The example displays the following output:
// System.Object
// </Snippet1>
}
}
// The example displays the following output:
// System.Object
// </Snippet1>