From fe46bbbeacd6de3a09e0167031f413761fbcfeb2 Mon Sep 17 00:00:00 2001 From: WilliamAntonRohm Date: Mon, 14 Oct 2019 15:21:06 -0700 Subject: [PATCH 1/2] updating for Try .NET --- .../CS/referenceequals.cs | 23 ++++++----------- .../system.object.equals/cs/equals_val1.cs | 11 ++++---- .../system.object.equals/cs/equalssb1.cs | 19 +++++++------- .../system.object.gettype/cs/GetTypeEx2.cs | 25 ++++++++----------- .../system.object.gettype/cs/gettype1.cs | 13 +++++----- .../cs/referenceequals4.cs | 13 +++++----- .../cs/referenceequalsa.cs | 17 +++++++------ .../system.object.tostring/cs/array1.cs | 13 +++++----- .../system.object.tostring/cs/tostring1.cs | 11 ++++---- 9 files changed, 71 insertions(+), 74 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CS/referenceequals.cs b/snippets/csharp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CS/referenceequals.cs index f66fa853679..ce5acd6f484 100644 --- a/snippets/csharp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CS/referenceequals.cs +++ b/snippets/csharp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CS/referenceequals.cs @@ -1,9 +1,9 @@ -// -using System; +using System; class MyClass { static void Main() { + // object o = null; object p = null; object q = new Object(); @@ -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 + // } } - - -/* - -This code produces the following output. - -True -True -False - -*/ -// - diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_val1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_val1.cs index 8117340f2b9..ea613774be1 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_val1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_val1.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // byte value1 = 12; int value2 = 12; @@ -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 + // } } -// The example displays the following output: -// 12 (Byte) = 12 (Int32): False -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs index 2b5cba70e1b..8d87c980e59 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs @@ -1,11 +1,11 @@ -// -using System; +using System; using System.Text; public class Example { public static void Main() { + // StringBuilder sb1 = new StringBuilder("building a string..."); StringBuilder sb2 = new StringBuilder("building a string..."); @@ -17,12 +17,13 @@ public static void Main() Object sb3 = new StringBuilder("building a string..."); Console.WriteLine("\nsb3.Equals(sb2): {0}", sb3.Equals(sb2)); + + // The example displays the following output: + // sb1.Equals(sb2): True + // ((Object) sb1).Equals(sb2): False + // Object.Equals(sb1, sb2): False + // + // sb3.Equals(sb2): False + // } } -// The example displays the following output: -// sb1.Equals(sb2): True -// ((Object) sb1).Equals(sb2): False -// Object.Equals(sb1, sb2): False -// -// sb3.Equals(sb2): False -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/GetTypeEx2.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/GetTypeEx2.cs index 1fd3a20ab96..f0a8201cc1d 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/GetTypeEx2.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/GetTypeEx2.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // object[] values = { (int) 12, (long) 10653, (byte) 12, (sbyte) -5, 16.3, "string" }; foreach (var value in values) { @@ -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. + // } } -// 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. -// - - - - diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs index 4fb60a451b6..c838b5db9e6 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // int n1 = 12; int n2 = 82; long n3 = 12; @@ -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 + // } } -// The example displays the following output: -// n1 and n2 are the same type: True -// n1 and n3 are the same type: False -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequals4.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequals4.cs index cd2dbc9bfac..9c3204be773 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequals4.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequals4.cs @@ -1,16 +1,17 @@ -// -using System; +using System; public class Example { public static void Main() { + // int int1 = 3; Console.WriteLine(Object.ReferenceEquals(int1, int1)); Console.WriteLine(int1.GetType().IsValueType); + + // The example displays the following output: + // False + // True + // } } -// The example displays the following output: -// False -// True -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequalsa.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequalsa.cs index 1d51f7cc289..b1192a99cc1 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequalsa.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequalsa.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // String s1 = "String1"; String s2 = "String1"; Console.WriteLine("s1 = s2: {0}", Object.ReferenceEquals(s1, s2)); @@ -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 + // } } -// The example displays the following output: -// s1 = s2: True -// String1 interned: Yes -// s3 = s4: False -// StringA interned: No -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/array1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/array1.cs index 65ee19f7cae..cf7b237be0c 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/array1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/array1.cs @@ -1,19 +1,20 @@ -// -using System; +using System; using System.Collections.Generic; public class Example { public static void Main() { + // int[] values = { 1, 2, 4, 8, 16, 32, 64, 128 }; Console.WriteLine(values.ToString()); List list = new List(values); Console.WriteLine(list.ToString()); + + // The example displays the following output: + // System.Int32[] + // System.Collections.Generic.List`1[System.Int32] + // } } -// The example displays the following output: -// System.Int32[] -// System.Collections.Generic.List`1[System.Int32] -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostring1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostring1.cs index cb40156da3f..4e1c698cdc2 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostring1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostring1.cs @@ -1,14 +1,15 @@ -// -using System; +using System; public class Example { public static void Main() { + // Object obj = new Object(); Console.WriteLine(obj.ToString()); + + // The example displays the following output: + // System.Object + // } } -// The example displays the following output: -// System.Object -// From 9a580925559d29732cc738ceb85e5792edfbcf93 Mon Sep 17 00:00:00 2001 From: WilliamAntonRohm Date: Tue, 15 Oct 2019 15:23:51 -0700 Subject: [PATCH 2/2] reverting per review --- .../system.object.equals/cs/equalssb1.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs index 8d87c980e59..2b5cba70e1b 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equalssb1.cs @@ -1,11 +1,11 @@ -using System; +// +using System; using System.Text; public class Example { public static void Main() { - // StringBuilder sb1 = new StringBuilder("building a string..."); StringBuilder sb2 = new StringBuilder("building a string..."); @@ -17,13 +17,12 @@ public static void Main() Object sb3 = new StringBuilder("building a string..."); Console.WriteLine("\nsb3.Equals(sb2): {0}", sb3.Equals(sb2)); - - // The example displays the following output: - // sb1.Equals(sb2): True - // ((Object) sb1).Equals(sb2): False - // Object.Equals(sb1, sb2): False - // - // sb3.Equals(sb2): False - // } } +// The example displays the following output: +// sb1.Equals(sb2): True +// ((Object) sb1).Equals(sb2): False +// Object.Equals(sb1, sb2): False +// +// sb3.Equals(sb2): False +//