From 19227f06b0ecc3c3e0139db38742cf42e3d9e704 Mon Sep 17 00:00:00 2001 From: WilliamAntonRohm Date: Thu, 8 Aug 2019 14:37:44 -0700 Subject: [PATCH 01/35] updating for Try .NET --- .../string.contains/CS/cont.cs | 33 ++++++++-------- .../string.length/CS/length.cs | 27 ++++++------- .../System.String.Contains/cs/ContainsExt1.cs | 13 ++++--- .../System.String.Substring/cs/Substring1.cs | 17 +++++---- .../System.String.Substring/cs/Substring10.cs | 35 ++++++++--------- .../System.String.Substring/cs/Substring2.cs | 11 +++--- .../System.String.Substring/cs/Substring3.cs | 13 ++++--- .../System.String.Substring/cs/Substring4.cs | 12 +++--- .../system.String.Compare/cs/Compare18.cs | 15 ++++---- .../system.String.Compare/cs/Example.cs | 15 ++++---- .../system.String.Compare/cs/compare02.cs | 15 ++++---- .../system.String.Compare/cs/compare21.cs | 11 +++--- .../system.String.Compare/cs/compare22.cs | 8 ++-- .../system.String.Compare/cs/compare23.cs | 12 +++--- .../system.String.IndexOf/CS/ignorable21.cs | 23 +++++------ .../system.String.IndexOf/CS/ignorable22.cs | 13 ++++--- .../system.String.IndexOf/CS/ignorable23.cs | 13 ++++--- .../system.String.IndexOf/CS/ignorable24.cs | 17 +++++---- .../system.String.IndexOf/CS/ignorable25.cs | 18 +++++---- .../system.String.IndexOf/CS/ignorable26.cs | 38 ++++++++++--------- .../system.String.IndexOf/CS/indexof_c.cs | 16 ++++---- .../system.String.IndexOf/CS/simple1.cs | 11 +++--- .../system.String.Trim/cs/Trim1.cs | 17 +++++---- .../system.String.Trim/cs/Trim2.cs | 21 +++++----- .../cs/NullString1.cs | 13 ++++--- .../system.string.replace/cs/replace1.cs | 13 ++++--- .../system.string.replace/cs/replace2.cs | 12 +++--- 27 files changed, 244 insertions(+), 218 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs b/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs index 9021723883e..4e98dfc795e 100644 --- a/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs +++ b/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs @@ -1,24 +1,25 @@ -// -using System; +using System; class Example { public static void Main() { - string s1 = "The quick brown fox jumps over the lazy dog"; - string s2 = "fox"; - bool b = s1.Contains(s2); - Console.WriteLine("'{0}' is in the string '{1}': {2}", - s2, s1, b); - if (b) { - int index = s1.IndexOf(s2); - if (index >= 0) - Console.WriteLine("'{0} begins at character position {1}", - s2, index + 1); + // + string s1 = "The quick brown fox jumps over the lazy dog"; + string s2 = "fox"; + bool b = s1.Contains(s2); + Console.WriteLine("'{0}' is in the string '{1}': {2}", + s2, s1, b); + if (b) { + int index = s1.IndexOf(s2); + if (index >= 0) + Console.WriteLine("'{0} begins at character position {1}", + s2, index + 1); + + // This example display the following output: + // 'fox' is in the string 'The quick brown fox jumps over the lazy dog': True + // 'fox begins at character position 17 + // } } } -// This example display the following output: -// 'fox' is in the string 'The quick brown fox jumps over the lazy dog': True -// 'fox begins at character position 17 -// \ No newline at end of file diff --git a/snippets/csharp/VS_Snippets_CLR/string.length/CS/length.cs b/snippets/csharp/VS_Snippets_CLR/string.length/CS/length.cs index 0ace269d883..a9b783a9178 100644 --- a/snippets/csharp/VS_Snippets_CLR/string.length/CS/length.cs +++ b/snippets/csharp/VS_Snippets_CLR/string.length/CS/length.cs @@ -1,20 +1,21 @@ -// -using System; +using System; class Sample { public static void Main() { - string str = "abcdefg"; - Console.WriteLine("1) The length of '{0}' is {1}", str, str.Length); - Console.WriteLine("2) The length of '{0}' is {1}", "xyz", "xyz".Length); - - int length = str.Length; - Console.WriteLine("3) The length of '{0}' is {1}", str, length); + // + string str = "abcdefg"; + Console.WriteLine("1) The length of '{0}' is {1}", str, str.Length); + Console.WriteLine("2) The length of '{0}' is {1}", "xyz", "xyz".Length); + + int length = str.Length; + Console.WriteLine("3) The length of '{0}' is {1}", str, length); + + // This example displays the following output: + // 1) The length of 'abcdefg' is 7 + // 2) The length of 'xyz' is 3 + // 3) The length of 'abcdefg' is 7 + // } } -// This example displays the following output: -// 1) The length of 'abcdefg' is 7 -// 2) The length of 'xyz' is 3 -// 3) The length of 'abcdefg' is 7 -// \ No newline at end of file diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs index 09ea5f2f11c..de6f5ce9eac 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs @@ -20,13 +20,13 @@ public static bool Contains(this String str, String substring, namespace App { -// using System; public class Example { public static void Main() { + // String s = "This is a string."; String sub1 = "this"; Console.WriteLine("Does '{0}' contain '{1}'?", s, sub1); @@ -35,13 +35,14 @@ public static void Main() comp = StringComparison.OrdinalIgnoreCase; Console.WriteLine(" {0:G}: {1}", comp, s.Contains(sub1, comp)); + + // The example displays the following output: + // Does 'This is a string.' contain 'this'? + // Ordinal: False + // OrdinalIgnoreCase: True + // } } -// The example displays the following output: -// Does 'This is a string.' contain 'this'? -// Ordinal: False -// OrdinalIgnoreCase: True -// } diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs index 7410a3d4afc..4753dd413b3 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // String[] pairs = { "Color1=red", "Color2=green", "Color3=blue", "Title=Code Repository" }; foreach (var pair in pairs) { @@ -15,11 +15,12 @@ public static void Main() pair.Substring(0, position), pair.Substring(position + 1)); } + + // The example displays the following output: + // Key: Color1, Value: 'red' + // Key: Color2, Value: 'green' + // Key: Color3, Value: 'blue' + // Key: Title, Value: 'Code Repository' + // } } -// The example displays the following output: -// Key: Color1, Value: 'red' -// Key: Color2, Value: 'green' -// Key: Color3, Value: 'blue' -// Key: Title, Value: 'Code Repository' -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs index ccb8c2bc203..c7798ed54fa 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs @@ -1,8 +1,8 @@ -// -using System; +using System; public class SubStringTest { public static void Main() { + // string [] info = { "Name: Felica Walker", "Title: Mz.", "Age: 47", "Location: Paris", "Gender: F"}; int found = 0; @@ -16,20 +16,21 @@ public static void Main() { found = s.IndexOf(": "); Console.WriteLine(" {0}", s.Substring(found + 2)); } + + // The example displays the following output: + // The initial values in the array are: + // Name: Felica Walker + // Title: Mz. + // Age: 47 + // Location: Paris + // Gender: F + // + // We want to retrieve only the key information. That is: + // Felica Walker + // Mz. + // 47 + // Paris + // F + // } } -// The example displays the following output: -// The initial values in the array are: -// Name: Felica Walker -// Title: Mz. -// Age: 47 -// Location: Paris -// Gender: F -// -// We want to retrieve only the key information. That is: -// Felica Walker -// Mz. -// 47 -// Paris -// F -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs index 7d5d449d06a..e689a225327 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // String s = "aaaaabbbcccccccdd"; Char charRange = 'b'; int startIndex = s.IndexOf(charRange); @@ -13,8 +13,9 @@ public static void Main() Console.WriteLine("{0}.Substring({1}, {2}) = {3}", s, startIndex, length, s.Substring(startIndex, length)); + + // The example displays the following output: + // aaaaabbbcccccccdd.Substring(5, 3) = bbb + // } } -// The example displays the following output: -// aaaaabbbcccccccdd.Substring(5, 3) = bbb -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs index 8fa96fef341..66460e833ec 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // String s = "extantstill in existence"; String searchString = ""; int startIndex = s.IndexOf(searchString); @@ -13,9 +13,10 @@ public static void Main() String substring = s.Substring(startIndex, endIndex + searchString.Length - startIndex); Console.WriteLine("Original string: {0}", s); Console.WriteLine("Substring; {0}", substring); + + // The example displays the following output: + // Original string: extantstill in existence + // Substring; still in existence + // } } -// The example displays the following output: -// Original string: extantstill in existence -// Substring; still in existence -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs index 44e287b8763..fbc44deaecc 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs @@ -1,18 +1,18 @@ -// -using System; +using System; public class Example { public static void Main() { + // String value = "This is a string."; int startIndex = 5; int length = 2; String substring = value.Substring(startIndex, length); Console.WriteLine(substring); + + // The example displays the following output: + // is + // } } -// The example displays the following output: -// is -// - diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs index 6dc02b42c68..aa62b247cfe 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // String s1, s2; s1 = "car"; s2 = "Car"; @@ -18,11 +18,12 @@ public static void Main() s1 = "mammal"; s2 = "fish"; Console.WriteLine("'{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2)); + + // The example displays the following output: + // 'car' and 'Car': -1 + // 'fork' and 'forks': -1 + // 'mammal' and 'fish': 1 + // } } -// The example displays the following output: -// car' and 'Car': -1 -// fork' and 'forks': -1 -// mammal' and 'fish': 1 -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs index 48cf8b49449..04017eefcf1 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs @@ -1,11 +1,11 @@ -// -using System; +using System; using System.Globalization; public class Example { public static void Main() { + // string string1 = "brother"; string string2 = "Brother"; string relation; @@ -48,10 +48,11 @@ public static void Main() Console.WriteLine("'{0}' {1} '{2}'.", string1, relation, string2); + + // The example produces the following output: + // 'brother' comes before 'Brother'. + // 'brother' is the same as 'Brother'. + // 'brother' comes after 'Brother'. + // } } -// The example produces the following output: -// 'brother' comes before 'Brother'. -// 'brother' is the same as 'Brother'. -// 'brother' comes after 'Brother'. -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs index 91c68f4dea5..3bac813261b 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs @@ -1,10 +1,10 @@ -// -using System; +using System; class Example { static void Main() { + // // Create upper-case characters from their Unicode code units. String stringUpper = "\x0041\x0042\x0043"; @@ -24,12 +24,13 @@ static void Main() Console.WriteLine("The Strings are equal when case is ignored? {0}", String.Compare(stringUpper, stringLower, true) == 0 ? "true" : "false" ); + + // The example displays the following output: + // Comparing 'ABC' and 'abc': + // The Strings are equal when capitalized? true + // The Strings are equal when case is ignored? true + // } } -// The example displays the following output: -// Comparing 'ABC' and 'abc': -// The Strings are equal when capitalized? true -// The Strings are equal when case is ignored? true -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs index a2579e81d15..c692c83283c 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs @@ -1,18 +1,19 @@ -// -using System; +using System; public class Example { public static void Main() { + // string s1 = "ani\u00ADmal"; string s2 = "animal"; Console.WriteLine("Comparison of '{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2)); + + // The example displays the following output: + // Comparison of 'ani-mal' and 'animal': 0 + // } } -// The example displays the following output: -// Comparison of 'ani-mal' and 'animal': 0 -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs index da320a7eb3e..d9e254640a7 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs @@ -10,9 +10,9 @@ public static void Main() Console.WriteLine("Comparison of '{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2, true)); + + // The example displays the following output: + // Comparison of 'ani-mal' and 'animal': 0 + // } } -// The example displays the following output: -// Comparison of 'ani-mal' and 'animal': 0 -// - diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs index 9733b3a2d60..7a237f3d926 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs @@ -1,20 +1,20 @@ -// -using System; +using System; using System.Globalization; public class Example { public static void Main() { + // string s1 = "Ani\u00ADmal"; string s2 = "animal"; Console.WriteLine("Comparison of '{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2, true, CultureInfo.InvariantCulture)); + + // The example displays the following output: + // Comparison of 'ani-mal' and 'animal': 0 + // } } -// The example displays the following output: -// Comparison of 'ani-mal' and 'animal': 0 -// - diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs index 6454cf6eefe..cff3f775d24 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // string s1 = "ani\u00ADmal"; string s2 = "animal"; @@ -19,15 +19,16 @@ public static void Main() // Find the index of the soft hyphen followed by "m". Console.WriteLine(s1.IndexOf("\u00ADm")); Console.WriteLine(s2.IndexOf("\u00ADm")); + + // The example displays the following output + // if run under the .NET Framework 4 or later: + // 0 + // 0 + // 1 + // 1 + // 4 + // 3 + // } } -// The example displays the following output -// if run under the .NET Framework 4 or later: -// 0 -// 0 -// 1 -// 1 -// 4 -// 3 -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs index 3c963c14dd6..961fa632080 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs @@ -1,19 +1,20 @@ -// -using System; +using System; public class Example { public static void Main() { + // string searchString = "\u00ADm"; string s1 = "ani\u00ADmal" ; string s2 = "animal"; Console.WriteLine(s1.IndexOf(searchString, 2)); Console.WriteLine(s2.IndexOf(searchString, 2)); + + // The example displays the following output: + // 4 + // 3 + // } } -// The example displays the following output: -// 4 -// 3 -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs index 7614d1a0895..ec87a337583 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs @@ -1,19 +1,20 @@ -// -using System; +using System; public class Example { public static void Main() { + // string searchString = "\u00ADm"; string s1 = "ani\u00ADmal" ; string s2 = "animal"; Console.WriteLine(s1.IndexOf(searchString, 2, 4)); Console.WriteLine(s2.IndexOf(searchString, 2, 4)); + + // The example displays the following output: + // 4 + // 3 + // } } -// The example displays the following output: -// 4 -// 3 -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs index ff6323f429b..625dea4ee45 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // string searchString = "\u00ADm"; string s1 = "ani\u00ADmal" ; string s2 = "animal"; @@ -13,11 +13,12 @@ public static void Main() Console.WriteLine(s1.IndexOf(searchString, 2, 4, StringComparison.Ordinal)); Console.WriteLine(s2.IndexOf(searchString, 2, 4, StringComparison.CurrentCulture)); Console.WriteLine(s2.IndexOf(searchString, 2, 4, StringComparison.Ordinal)); + + // The example displays the following output: + // 4 + // 3 + // 3 + // -1 + // } } -// The example displays the following output: -// 4 -// 3 -// 3 -// -1 -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs index ddf7066bce8..6e14dd808c8 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // string searchString = "\u00ADm"; string s1 = "ani\u00ADmal" ; string s2 = "animal"; @@ -13,11 +13,13 @@ public static void Main() Console.WriteLine(s1.IndexOf(searchString, 2, StringComparison.Ordinal)); Console.WriteLine(s2.IndexOf(searchString, 2, StringComparison.CurrentCulture)); Console.WriteLine(s2.IndexOf(searchString, 2, StringComparison.Ordinal)); + + // The example displays the following output: + // 4 + // 3 + // 3 + // -1 + // } } -// The example displays the following output: -// 4 -// 3 -// 3 -// -1 -// + diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs index 1dcf77b0177..16bd2e1b9bb 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // string s1 = "ani\u00ADmal"; string s2 = "animal"; @@ -33,22 +33,24 @@ public static void Main() // Use ordinal comparison to find the soft hyphen followed by "m". Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.Ordinal)); Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.Ordinal)); + + // The example displays the following output: + // Culture-sensitive comparison: + // 0 + // 0 + // 1 + // 1 + // 4 + // 3 + // Ordinal comparison: + // 3 + // -1 + // -1 + // -1 + // 3 + // -1 + // } } -// The example displays the following output: -// Culture-sensitive comparison: -// 0 -// 0 -// 1 -// 1 -// 4 -// 3 -// Ordinal comparison: -// 3 -// -1 -// -1 -// -1 -// 3 -// -1 -// + diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs index 1e470fca668..7f1863772ae 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs @@ -1,10 +1,10 @@ -// -using System; +using System; class Example { static void Main() { + // // Create a Unicode string with 5 Greek Alpha characters. String szGreekAlpha = new String('\u0391',5); @@ -26,11 +26,13 @@ static void Main() ialpha); Console.WriteLine("First occurrence of the Greek letter Omega: Index {0}", iomega); + + // The example displays the following output: + // The string: OOO?????OOO + // First occurrence of the Greek letter Alpha: Index 3 + // First occurrence of the Greek letter Omega: Index 0 + // } } -// The example displays the following output: -// The string: OOO?????OOO -// First occurrence of the Greek letter Alpha: Index 3 -// First occurrence of the Greek letter Omega: Index 0 -// + diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs index cb2b1016a59..6d0467fcf92 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs @@ -1,17 +1,18 @@ -// -using System; +using System; public class Example { public static void Main() { + // String str = "animal"; String toFind = "n"; int index = str.IndexOf("n"); Console.WriteLine("Found '{0}' in '{1}' at position {2}", toFind, str, index); + + // The example displays the following output: + // Found 'n' in 'animal' at position 1 + // } } -// The example displays the following output: -// Found 'n' in 'animal' at position 1 -// \ No newline at end of file diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs index 8c543e0955f..5a76478b9e2 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs @@ -1,19 +1,20 @@ -// -using System; +using System; public class Example { public static void Main() { + // char[] charsToTrim = { '*', ' ', '\''}; string banner = "*** Much Ado About Nothing ***"; string result = banner.Trim(charsToTrim); Console.WriteLine("Trimmmed\n {0}\nto\n '{1}'", banner, result); + + // The example displays the following output: + // Trimmmed + // *** Much Ado About Nothing *** + // to + // 'Much Ado About Nothing' + // } } -// The example displays the following output: -// Trimmmed -// *** Much Ado About Nothing *** -// to -// 'Much Ado About Nothing' -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs index ffcdb751800..e777cba7ab3 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // Console.Write("Enter your first name: "); string firstName = Console.ReadLine(); @@ -21,13 +21,14 @@ public static void Main() string name = ((firstName.Trim() + " " + middleName.Trim()).Trim() + " " + lastName.Trim()).Trim(); Console.WriteLine("The result is " + name + "."); + + // The following is possible output from this example: + // Enter your first name: John + // Enter your middle name or initial: + // Enter your last name: Doe + // + // You entered ' John ', '', and ' Doe'. + // The result is John Doe. + // } } -// The following is possible output from this example: -// Enter your first name: John -// Enter your middle name or initial: -// Enter your last name: Doe -// -// You entered ' John ', '', and ' Doe'. -// The result is John Doe. -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs index 85b46b508a3..7f113c45b72 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs @@ -1,10 +1,10 @@ -// -using System; +using System; public class Example { public static void Main() { + // String s = null; Console.WriteLine("The value of the string is '{0}'", s); @@ -15,12 +15,13 @@ public static void Main() catch (NullReferenceException e) { Console.WriteLine(e.Message); } + + // The example displays the following output: + // The value of the string is '' + // Object reference not set to an instance of an object. + // } } -// The example displays the following output: -// The value of the string is '' -// Object reference not set to an instance of an object. -// public class Empty { diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs index ef843f9af85..882e7014d04 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs @@ -1,17 +1,18 @@ -// -using System; +using System; public class Example { public static void Main() { + // String s = "aaa"; Console.WriteLine("The initial string: '{0}'", s); s = s.Replace("a", "b").Replace("b", "c").Replace("c", "d"); Console.WriteLine("The final string: '{0}'", s); + + // The example displays the following output: + // The initial string: 'aaa' + // The final string: 'ddd' + // } } -// The example displays the following output: -// The initial string: 'aaa' -// The final string: 'ddd' -// diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs index bd1e03510e3..8e84df2fbe5 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs @@ -1,17 +1,17 @@ -// -using System; +using System; public class Example { public static void Main() { + // String s = new String('a', 3); Console.WriteLine("The initial string: '{0}'", s); s = s.Replace('a', 'b').Replace('b', 'c').Replace('c', 'd'); Console.WriteLine("The final string: '{0}'", s); + // The example displays the following output: + // The initial string: 'aaa' + // The final string: 'ddd' + // } } -// The example displays the following output: -// The initial string: 'aaa' -// The final string: 'ddd' -// From 713445dfa59873afe3f351662067b8409187294e Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:20:58 -0700 Subject: [PATCH 02/35] fix indentation and moved comments --- .../string.contains/CS/cont.cs | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs b/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs index 4e98dfc795e..86fa86b3a23 100644 --- a/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs +++ b/snippets/csharp/VS_Snippets_CLR/string.contains/CS/cont.cs @@ -4,22 +4,21 @@ class Example { public static void Main() { - // - string s1 = "The quick brown fox jumps over the lazy dog"; - string s2 = "fox"; - bool b = s1.Contains(s2); - Console.WriteLine("'{0}' is in the string '{1}': {2}", + // + string s1 = "The quick brown fox jumps over the lazy dog"; + string s2 = "fox"; + bool b = s1.Contains(s2); + Console.WriteLine("'{0}' is in the string '{1}': {2}", s2, s1, b); - if (b) { - int index = s1.IndexOf(s2); - if (index >= 0) - Console.WriteLine("'{0} begins at character position {1}", - s2, index + 1); - - // This example display the following output: - // 'fox' is in the string 'The quick brown fox jumps over the lazy dog': True - // 'fox begins at character position 17 - // - } + if (b) { + int index = s1.IndexOf(s2); + if (index >= 0) + Console.WriteLine("'{0} begins at character position {1}", + s2, index + 1); + } + // This example display the following output: + // 'fox' is in the string 'The quick brown fox jumps over the lazy dog': True + // 'fox begins at character position 17 + // } } From 262ca1e2838993d25e37eb812ad88b8b5efa4777 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:24:45 -0700 Subject: [PATCH 03/35] fix indentation --- .../System.String.Contains/cs/ContainsExt1.cs | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs index de6f5ce9eac..a77eec8322e 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Contains/cs/ContainsExt1.cs @@ -6,14 +6,14 @@ public static class StringExtensions public static bool Contains(this String str, String substring, StringComparison comp) { - if (substring == null) - throw new ArgumentNullException("substring", + if (substring == null) + throw new ArgumentNullException("substring", "substring cannot be null."); - else if (! Enum.IsDefined(typeof(StringComparison), comp)) - throw new ArgumentException("comp is not a member of StringComparison", + else if (! Enum.IsDefined(typeof(StringComparison), comp)) + throw new ArgumentException("comp is not a member of StringComparison", "comp"); - return str.IndexOf(substring, comp) >= 0; + return str.IndexOf(substring, comp) >= 0; } } // @@ -24,24 +24,24 @@ namespace App public class Example { - public static void Main() - { - // - String s = "This is a string."; - String sub1 = "this"; - Console.WriteLine("Does '{0}' contain '{1}'?", s, sub1); - StringComparison comp = StringComparison.Ordinal; - Console.WriteLine(" {0:G}: {1}", comp, s.Contains(sub1, comp)); - - comp = StringComparison.OrdinalIgnoreCase; - Console.WriteLine(" {0:G}: {1}", comp, s.Contains(sub1, comp)); - - // The example displays the following output: - // Does 'This is a string.' contain 'this'? - // Ordinal: False - // OrdinalIgnoreCase: True - // - } + public static void Main() + { + // + String s = "This is a string."; + String sub1 = "this"; + Console.WriteLine("Does '{0}' contain '{1}'?", s, sub1); + StringComparison comp = StringComparison.Ordinal; + Console.WriteLine(" {0:G}: {1}", comp, s.Contains(sub1, comp)); + + comp = StringComparison.OrdinalIgnoreCase; + Console.WriteLine(" {0:G}: {1}", comp, s.Contains(sub1, comp)); + + // The example displays the following output: + // Does 'This is a string.' contain 'this'? + // Ordinal: False + // OrdinalIgnoreCase: True + // + } } } From 11b8b5cfadc916f12869112d424eee8b516b4f88 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:25:51 -0700 Subject: [PATCH 04/35] fix indentation --- .../System.String.Substring/cs/Substring1.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs index 4753dd413b3..5c2247cb989 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring1.cs @@ -2,25 +2,25 @@ public class Example { - public static void Main() - { - // - String[] pairs = { "Color1=red", "Color2=green", "Color3=blue", + public static void Main() + { + // + String[] pairs = { "Color1=red", "Color2=green", "Color3=blue", "Title=Code Repository" }; - foreach (var pair in pairs) { - int position = pair.IndexOf("="); - if (position < 0) - continue; - Console.WriteLine("Key: {0}, Value: '{1}'", + foreach (var pair in pairs) { + int position = pair.IndexOf("="); + if (position < 0) + continue; + Console.WriteLine("Key: {0}, Value: '{1}'", pair.Substring(0, position), pair.Substring(position + 1)); - } + } - // The example displays the following output: - // Key: Color1, Value: 'red' - // Key: Color2, Value: 'green' - // Key: Color3, Value: 'blue' - // Key: Title, Value: 'Code Repository' - // - } + // The example displays the following output: + // Key: Color1, Value: 'red' + // Key: Color2, Value: 'green' + // Key: Color3, Value: 'blue' + // Key: Title, Value: 'Code Repository' + // + } } From e85a12ecf309cb2be7be99e382a39fc416bc8504 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:26:56 -0700 Subject: [PATCH 05/35] use Allman style --- .../System.String.Substring/cs/Substring10.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs index c7798ed54fa..506c299b6a9 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring10.cs @@ -1,7 +1,9 @@ using System; -public class SubStringTest { - public static void Main() { +public class SubStringTest +{ + public static void Main() + { // string [] info = { "Name: Felica Walker", "Title: Mz.", "Age: 47", "Location: Paris", "Gender: F"}; @@ -12,7 +14,8 @@ public static void Main() { Console.WriteLine(s); Console.WriteLine("\nWe want to retrieve only the key information. That is:"); - foreach (string s in info) { + foreach (string s in info) + { found = s.IndexOf(": "); Console.WriteLine(" {0}", s.Substring(found + 2)); } From 42ce72a90cdc9a1941d3842f585a9837cb2b0443 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:27:55 -0700 Subject: [PATCH 06/35] fix indentation --- .../System.String.Substring/cs/Substring2.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs index e689a225327..acd79845e84 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring2.cs @@ -2,20 +2,20 @@ public class Example { - public static void Main() - { - // - String s = "aaaaabbbcccccccdd"; - Char charRange = 'b'; - int startIndex = s.IndexOf(charRange); - int endIndex = s.LastIndexOf(charRange); - int length = endIndex - startIndex + 1; - Console.WriteLine("{0}.Substring({1}, {2}) = {3}", + public static void Main() + { + // + String s = "aaaaabbbcccccccdd"; + Char charRange = 'b'; + int startIndex = s.IndexOf(charRange); + int endIndex = s.LastIndexOf(charRange); + int length = endIndex - startIndex + 1; + Console.WriteLine("{0}.Substring({1}, {2}) = {3}", s, startIndex, length, s.Substring(startIndex, length)); - // The example displays the following output: - // aaaaabbbcccccccdd.Substring(5, 3) = bbb - // - } + // The example displays the following output: + // aaaaabbbcccccccdd.Substring(5, 3) = bbb + // + } } From 409a65e39d5a37fb744c73471ebb07c04b5825bf Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:28:47 -0700 Subject: [PATCH 07/35] fix indentation --- .../System.String.Substring/cs/Substring3.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs index 66460e833ec..416aec100d2 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring3.cs @@ -2,21 +2,21 @@ public class Example { - public static void Main() - { - // - String s = "extantstill in existence"; - String searchString = ""; - int startIndex = s.IndexOf(searchString); - searchString = " + String s = "extantstill in existence"; + String searchString = ""; + int startIndex = s.IndexOf(searchString); + searchString = "extantstill in existence - // Substring; still in existence - // - } + // The example displays the following output: + // Original string: extantstill in existence + // Substring; still in existence + // + } } From 192bcec757cb4b4ba70d517198c70e4698eb5c57 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:29:30 -0700 Subject: [PATCH 08/35] fix indentation --- .../System.String.Substring/cs/Substring4.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs index fbc44deaecc..2e53ac13007 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/System.String.Substring/cs/Substring4.cs @@ -2,17 +2,17 @@ public class Example { - public static void Main() - { - // - String value = "This is a string."; - int startIndex = 5; - int length = 2; - String substring = value.Substring(startIndex, length); - Console.WriteLine(substring); + public static void Main() + { + // + String value = "This is a string."; + int startIndex = 5; + int length = 2; + String substring = value.Substring(startIndex, length); + Console.WriteLine(substring); - // The example displays the following output: - // is - // - } + // The example displays the following output: + // is + // + } } From b718abf1aa681a9d2a81927de2717f1e0d0b73df Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:30:18 -0700 Subject: [PATCH 09/35] fix indentation --- .../system.String.Compare/cs/Compare18.cs | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs index aa62b247cfe..7eb7813d38d 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Compare18.cs @@ -2,28 +2,27 @@ public class Example { - public static void Main() - { - // - String s1, s2; - - s1 = "car"; s2 = "Car"; - Console.WriteLine("'{0}' and '{1}': {2}", s1, s2, + public static void Main() + { + // + String s1, s2; + + s1 = "car"; s2 = "Car"; + Console.WriteLine("'{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2)); - s1 = "fork"; s2 = "forks"; - Console.WriteLine("'{0}' and '{1}': {2}", s1, s2, + s1 = "fork"; s2 = "forks"; + Console.WriteLine("'{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2)); - s1 = "mammal"; s2 = "fish"; - Console.WriteLine("'{0}' and '{1}': {2}", s1, s2, + s1 = "mammal"; s2 = "fish"; + Console.WriteLine("'{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2)); - // The example displays the following output: - // 'car' and 'Car': -1 - // 'fork' and 'forks': -1 - // 'mammal' and 'fish': 1 - // - } + // The example displays the following output: + // 'car' and 'Car': -1 + // 'fork' and 'forks': -1 + // 'mammal' and 'fish': 1 + // + } } - From c2203f3150e74182e5f09d2450df5d9885654167 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:32:10 -0700 Subject: [PATCH 10/35] fix indentation --- .../system.String.Compare/cs/Example.cs | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs index 04017eefcf1..99771a651b6 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/Example.cs @@ -3,56 +3,56 @@ public class Example { - public static void Main() - { - // - string string1 = "brother"; - string string2 = "Brother"; - string relation; - int result; - - // Cultural (linguistic) comparison. - result = String.Compare(string1, string2, new CultureInfo("en-US"), + public static void Main() + { + // + string string1 = "brother"; + string string2 = "Brother"; + string relation; + int result; + + // Cultural (linguistic) comparison. + result = String.Compare(string1, string2, new CultureInfo("en-US"), CompareOptions.None); - if (result > 0) - relation = "comes after"; - else if (result == 0) - relation = "is the same as"; - else - relation = "comes before"; + if (result > 0) + relation = "comes after"; + else if (result == 0) + relation = "is the same as"; + else + relation = "comes before"; - Console.WriteLine("'{0}' {1} '{2}'.", + Console.WriteLine("'{0}' {1} '{2}'.", string1, relation, string2); - // Cultural (linguistic) case-insensitive comparison. - result = String.Compare(string1, string2, new CultureInfo("en-US"), + // Cultural (linguistic) case-insensitive comparison. + result = String.Compare(string1, string2, new CultureInfo("en-US"), CompareOptions.IgnoreCase); - if (result > 0) - relation = "comes after"; - else if (result == 0) - relation = "is the same as"; - else - relation = "comes before"; + if (result > 0) + relation = "comes after"; + else if (result == 0) + relation = "is the same as"; + else + relation = "comes before"; - Console.WriteLine("'{0}' {1} '{2}'.", + Console.WriteLine("'{0}' {1} '{2}'.", string1, relation, string2); - // Culture-insensitive ordinal comparison. - result = String.CompareOrdinal(string1, string2); - if (result > 0) - relation = "comes after"; - else if (result == 0) - relation = "is the same as"; - else - relation = "comes before"; + // Culture-insensitive ordinal comparison. + result = String.CompareOrdinal(string1, string2); + if (result > 0) + relation = "comes after"; + else if (result == 0) + relation = "is the same as"; + else + relation = "comes before"; - Console.WriteLine("'{0}' {1} '{2}'.", + Console.WriteLine("'{0}' {1} '{2}'.", string1, relation, string2); - // The example produces the following output: - // 'brother' comes before 'Brother'. - // 'brother' is the same as 'Brother'. - // 'brother' comes after 'Brother'. - // - } + // The example produces the following output: + // 'brother' comes before 'Brother'. + // 'brother' is the same as 'Brother'. + // 'brother' comes after 'Brother'. + // + } } From b1b1c9a4427992531974c3b9c5b3f2b0305a0467 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:33:05 -0700 Subject: [PATCH 11/35] fix indentation --- .../system.String.Compare/cs/compare02.cs | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs index 3bac813261b..d9335e5a87d 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare02.cs @@ -2,35 +2,33 @@ class Example { - static void Main() - { - // - // Create upper-case characters from their Unicode code units. - String stringUpper = "\x0041\x0042\x0043"; + static void Main() + { + // + // Create upper-case characters from their Unicode code units. + String stringUpper = "\x0041\x0042\x0043"; - // Create lower-case characters from their Unicode code units. - String stringLower = "\x0061\x0062\x0063"; + // Create lower-case characters from their Unicode code units. + String stringLower = "\x0061\x0062\x0063"; - // Display the strings. - Console.WriteLine("Comparing '{0}' and '{1}':", + // Display the strings. + Console.WriteLine("Comparing '{0}' and '{1}':", stringUpper, stringLower); - // Compare the uppercased strings; the result is true. - Console.WriteLine("The Strings are equal when capitalized? {0}", + // Compare the uppercased strings; the result is true. + Console.WriteLine("The Strings are equal when capitalized? {0}", String.Compare(stringUpper.ToUpper(), stringLower.ToUpper()) == 0 ? "true" : "false"); - // The previous method call is equivalent to this Compare method, which ignores case. - Console.WriteLine("The Strings are equal when case is ignored? {0}", + // The previous method call is equivalent to this Compare method, which ignores case. + Console.WriteLine("The Strings are equal when case is ignored? {0}", String.Compare(stringUpper, stringLower, true) == 0 ? "true" : "false" ); - // The example displays the following output: - // Comparing 'ABC' and 'abc': - // The Strings are equal when capitalized? true - // The Strings are equal when case is ignored? true - // - } -} - - + // The example displays the following output: + // Comparing 'ABC' and 'abc': + // The Strings are equal when capitalized? true + // The Strings are equal when case is ignored? true + // + } +} From 4dd81a2cd066687a5134b9fe76b9956e4c46df8f Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:33:45 -0700 Subject: [PATCH 12/35] fix indentation --- .../system.String.Compare/cs/compare21.cs | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs index c692c83283c..74169dd29ad 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs @@ -2,18 +2,17 @@ public class Example { - public static void Main() - { - // - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - Console.WriteLine("Comparison of '{0}' and '{1}': {2}", + public static void Main() + { + // + string s1 = "ani\u00ADmal"; + string s2 = "animal"; + + Console.WriteLine("Comparison of '{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2)); - // The example displays the following output: - // Comparison of 'ani-mal' and 'animal': 0 - // - } + // The example displays the following output: + // Comparison of 'ani-mal' and 'animal': 0 + // + } } - From 39678f05594e0bbd55f6c17e853bc8cec5e473cd Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:34:17 -0700 Subject: [PATCH 13/35] fix indentation --- .../system.String.Compare/cs/compare22.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs index d9e254640a7..04416f6318c 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs @@ -3,16 +3,16 @@ public class Example { - public static void Main() - { - string s1 = "Ani\u00ADmal"; - string s2 = "animal"; + public static void Main() + { + string s1 = "Ani\u00ADmal"; + string s2 = "animal"; - Console.WriteLine("Comparison of '{0}' and '{1}': {2}", + Console.WriteLine("Comparison of '{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2, true)); - // The example displays the following output: - // Comparison of 'ani-mal' and 'animal': 0 - // - } + // The example displays the following output: + // Comparison of 'ani-mal' and 'animal': 0 + // + } } From 4a85e8b37eced855cff1b97fc6133785ddf176e3 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:34:54 -0700 Subject: [PATCH 14/35] fix indentation --- .../system.String.Compare/cs/compare23.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs index 7a237f3d926..62c390196ae 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs @@ -3,18 +3,18 @@ public class Example { - public static void Main() - { - // - string s1 = "Ani\u00ADmal"; - string s2 = "animal"; + public static void Main() + { + // + string s1 = "Ani\u00ADmal"; + string s2 = "animal"; - Console.WriteLine("Comparison of '{0}' and '{1}': {2}", + Console.WriteLine("Comparison of '{0}' and '{1}': {2}", s1, s2, String.Compare(s1, s2, true, CultureInfo.InvariantCulture)); - // The example displays the following output: - // Comparison of 'ani-mal' and 'animal': 0 - // - } + // The example displays the following output: + // Comparison of 'ani-mal' and 'animal': 0 + // + } } From 95e7f205664fd46e1a462e56e3693e39bf6b57d1 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:35:38 -0700 Subject: [PATCH 15/35] fix indentation --- .../system.String.IndexOf/CS/ignorable21.cs | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs index cff3f775d24..2d12038bdcb 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs @@ -2,33 +2,32 @@ public class Example { - public static void Main() - { - // - string s1 = "ani\u00ADmal"; - string s2 = "animal"; + public static void Main() + { + // + string s1 = "ani\u00ADmal"; + string s2 = "animal"; - // Find the index of the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD")); - Console.WriteLine(s2.IndexOf("\u00AD")); + // Find the index of the soft hyphen. + Console.WriteLine(s1.IndexOf("\u00AD")); + Console.WriteLine(s2.IndexOf("\u00AD")); - // Find the index of the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn")); - Console.WriteLine(s2.IndexOf("\u00ADn")); + // Find the index of the soft hyphen followed by "n". + Console.WriteLine(s1.IndexOf("\u00ADn")); + Console.WriteLine(s2.IndexOf("\u00ADn")); - // Find the index of the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm")); - Console.WriteLine(s2.IndexOf("\u00ADm")); + // Find the index of the soft hyphen followed by "m". + Console.WriteLine(s1.IndexOf("\u00ADm")); + Console.WriteLine(s2.IndexOf("\u00ADm")); - // The example displays the following output - // if run under the .NET Framework 4 or later: - // 0 - // 0 - // 1 - // 1 - // 4 - // 3 - // - } + // The example displays the following output + // if run under the .NET Framework 4 or later: + // 0 + // 0 + // 1 + // 1 + // 4 + // 3 + // + } } - From f66aef2f06c2f1cecf4966df3e46d784dccd6307 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:36:14 -0700 Subject: [PATCH 16/35] fix indentation --- .../system.String.IndexOf/CS/ignorable22.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs index 961fa632080..d6aa0d2a1f0 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs @@ -2,19 +2,19 @@ public class Example { - public static void Main() - { - // - string searchString = "\u00ADm"; - string s1 = "ani\u00ADmal" ; - string s2 = "animal"; + public static void Main() + { + // + string searchString = "\u00ADm"; + string s1 = "ani\u00ADmal" ; + string s2 = "animal"; - Console.WriteLine(s1.IndexOf(searchString, 2)); - Console.WriteLine(s2.IndexOf(searchString, 2)); + Console.WriteLine(s1.IndexOf(searchString, 2)); + Console.WriteLine(s2.IndexOf(searchString, 2)); - // The example displays the following output: - // 4 - // 3 - // - } + // The example displays the following output: + // 4 + // 3 + // + } } From f614b71796a6a7d02248b29d3839cd6d21af2599 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:36:49 -0700 Subject: [PATCH 17/35] fix indentation --- .../system.String.IndexOf/CS/ignorable23.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs index ec87a337583..562ad95289d 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs @@ -2,19 +2,19 @@ public class Example { - public static void Main() - { - // - string searchString = "\u00ADm"; - string s1 = "ani\u00ADmal" ; - string s2 = "animal"; + public static void Main() + { + // + string searchString = "\u00ADm"; + string s1 = "ani\u00ADmal" ; + string s2 = "animal"; - Console.WriteLine(s1.IndexOf(searchString, 2, 4)); - Console.WriteLine(s2.IndexOf(searchString, 2, 4)); + Console.WriteLine(s1.IndexOf(searchString, 2, 4)); + Console.WriteLine(s2.IndexOf(searchString, 2, 4)); - // The example displays the following output: - // 4 - // 3 - // - } + // The example displays the following output: + // 4 + // 3 + // + } } From 2bd17c6422cf20058e7e5b3b2db0294925241672 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:46:06 -0700 Subject: [PATCH 18/35] undo change + indentation --- .../system.String.IndexOf/CS/ignorable24.cs | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs index 625dea4ee45..e2933e6313b 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs @@ -1,24 +1,26 @@ -using System; + +// +using System; public class Example { - public static void Main() - { - // - string searchString = "\u00ADm"; - string s1 = "ani\u00ADmal" ; - string s2 = "animal"; + public static void Main() + { - Console.WriteLine(s1.IndexOf(searchString, 2, 4, StringComparison.CurrentCulture)); - Console.WriteLine(s1.IndexOf(searchString, 2, 4, StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf(searchString, 2, 4, StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf(searchString, 2, 4, StringComparison.Ordinal)); + string searchString = "\u00ADm"; + string s1 = "ani\u00ADmal" ; + string s2 = "animal"; - // The example displays the following output: - // 4 - // 3 - // 3 - // -1 - // - } + Console.WriteLine(s1.IndexOf(searchString, 2, 4, StringComparison.CurrentCulture)); + Console.WriteLine(s1.IndexOf(searchString, 2, 4, StringComparison.Ordinal)); + Console.WriteLine(s2.IndexOf(searchString, 2, 4, StringComparison.CurrentCulture)); + Console.WriteLine(s2.IndexOf(searchString, 2, 4, StringComparison.Ordinal)); + + // The example displays the following output: + // 4 + // 3 + // 3 + // -1 + } } +// From c8140e7647f6f15b424c55664b1c6d271ed61ff1 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:46:24 -0700 Subject: [PATCH 19/35] remove extra line --- .../system.String.IndexOf/CS/ignorable24.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs index e2933e6313b..c63cb7df854 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable24.cs @@ -1,5 +1,4 @@ - -// +// using System; public class Example From ed6ecfb0420877e418462721affddc63f61f631d Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:48:18 -0700 Subject: [PATCH 20/35] undo change + indentation --- .../system.String.IndexOf/CS/ignorable25.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs index 6e14dd808c8..b5d9fafe11a 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable25.cs @@ -1,25 +1,25 @@ -using System; +// +using System; public class Example { - public static void Main() - { - // - string searchString = "\u00ADm"; - string s1 = "ani\u00ADmal" ; - string s2 = "animal"; + public static void Main() + { + + string searchString = "\u00ADm"; + string s1 = "ani\u00ADmal" ; + string s2 = "animal"; - Console.WriteLine(s1.IndexOf(searchString, 2, StringComparison.CurrentCulture)); - Console.WriteLine(s1.IndexOf(searchString, 2, StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf(searchString, 2, StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf(searchString, 2, StringComparison.Ordinal)); + Console.WriteLine(s1.IndexOf(searchString, 2, StringComparison.CurrentCulture)); + Console.WriteLine(s1.IndexOf(searchString, 2, StringComparison.Ordinal)); + Console.WriteLine(s2.IndexOf(searchString, 2, StringComparison.CurrentCulture)); + Console.WriteLine(s2.IndexOf(searchString, 2, StringComparison.Ordinal)); - // The example displays the following output: - // 4 - // 3 - // 3 - // -1 - // - } + // The example displays the following output: + // 4 + // 3 + // 3 + // -1 + } } - +// From 357a74183a020cd598a7d2bdc48189e146281d1b Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:50:04 -0700 Subject: [PATCH 21/35] undo change + indentation --- .../system.String.IndexOf/CS/ignorable26.cs | 88 +++++++++---------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs index 16bd2e1b9bb..61944637145 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable26.cs @@ -1,56 +1,54 @@ -using System; +// +using System; public class Example { - public static void Main() - { - // - string s1 = "ani\u00ADmal"; - string s2 = "animal"; + public static void Main() + { + string s1 = "ani\u00ADmal"; + string s2 = "animal"; - Console.WriteLine("Culture-sensitive comparison:"); - // Use culture-sensitive comparison to find the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.CurrentCulture)); + Console.WriteLine("Culture-sensitive comparison:"); + // Use culture-sensitive comparison to find the soft hyphen. + Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.CurrentCulture)); + Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.CurrentCulture)); - // Use culture-sensitive comparison to find the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.CurrentCulture)); + // Use culture-sensitive comparison to find the soft hyphen followed by "n". + Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.CurrentCulture)); + Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.CurrentCulture)); - // Use culture-sensitive comparison to find the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.CurrentCulture)); + // Use culture-sensitive comparison to find the soft hyphen followed by "m". + Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.CurrentCulture)); + Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.CurrentCulture)); - Console.WriteLine("Ordinal comparison:"); - // Use ordinal comparison to find the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.Ordinal)); + Console.WriteLine("Ordinal comparison:"); + // Use ordinal comparison to find the soft hyphen. + Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.Ordinal)); + Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.Ordinal)); - // Use ordinal comparison to find the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.Ordinal)); + // Use ordinal comparison to find the soft hyphen followed by "n". + Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.Ordinal)); + Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.Ordinal)); - // Use ordinal comparison to find the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.Ordinal)); + // Use ordinal comparison to find the soft hyphen followed by "m". + Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.Ordinal)); + Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.Ordinal)); - // The example displays the following output: - // Culture-sensitive comparison: - // 0 - // 0 - // 1 - // 1 - // 4 - // 3 - // Ordinal comparison: - // 3 - // -1 - // -1 - // -1 - // 3 - // -1 - // - } + // The example displays the following output: + // Culture-sensitive comparison: + // 0 + // 0 + // 1 + // 1 + // 4 + // 3 + // Ordinal comparison: + // 3 + // -1 + // -1 + // -1 + // 3 + // -1 + } } - - +// From cba909ee1902e03021156588dcc72122bdbcc494 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:52:03 -0700 Subject: [PATCH 22/35] fix indentation + output --- .../system.String.IndexOf/CS/indexof_c.cs | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs index 7f1863772ae..2b7c273d005 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/indexof_c.cs @@ -2,37 +2,35 @@ class Example { - static void Main() - { - // - // Create a Unicode string with 5 Greek Alpha characters. - String szGreekAlpha = new String('\u0391',5); + static void Main() + { + // + // Create a Unicode string with 5 Greek Alpha characters. + String szGreekAlpha = new String('\u0391',5); - // Create a Unicode string with 3 Greek Omega characters. - String szGreekOmega = "\u03A9\u03A9\u03A9"; - - String szGreekLetters = String.Concat(szGreekOmega, szGreekAlpha, + // Create a Unicode string with 3 Greek Omega characters. + String szGreekOmega = "\u03A9\u03A9\u03A9"; + + String szGreekLetters = String.Concat(szGreekOmega, szGreekAlpha, szGreekOmega.Clone()); - // Display the entire string. - Console.WriteLine("The string: {0}", szGreekLetters); + // Display the entire string. + Console.WriteLine("The string: {0}", szGreekLetters); - // The first index of Alpha. - int ialpha = szGreekLetters.IndexOf('\u0391'); - // The first index of Omega. - int iomega = szGreekLetters.IndexOf('\u03A9'); + // The first index of Alpha. + int ialpha = szGreekLetters.IndexOf('\u0391'); + // The first index of Omega. + int iomega = szGreekLetters.IndexOf('\u03A9'); - Console.WriteLine("First occurrence of the Greek letter Alpha: Index {0}", + Console.WriteLine("First occurrence of the Greek letter Alpha: Index {0}", ialpha); - Console.WriteLine("First occurrence of the Greek letter Omega: Index {0}", + Console.WriteLine("First occurrence of the Greek letter Omega: Index {0}", iomega); - // The example displays the following output: - // The string: OOO?????OOO - // First occurrence of the Greek letter Alpha: Index 3 - // First occurrence of the Greek letter Omega: Index 0 - // - } -} - - + // The example displays the following output: + // The string: ΩΩΩΑΑΑΑΑΩΩΩ + // First occurrence of the Greek letter Alpha: Index 3 + // First occurrence of the Greek letter Omega: Index 0 + // + } +} From 5a2b36b1bc6a8a53e663b43a3de49fa5ab8ba16a Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:52:37 -0700 Subject: [PATCH 23/35] fix indentation --- .../system.String.IndexOf/CS/simple1.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs index 6d0467fcf92..f95f43a3db8 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/simple1.cs @@ -2,17 +2,17 @@ public class Example { - public static void Main() - { - // - String str = "animal"; - String toFind = "n"; - int index = str.IndexOf("n"); - Console.WriteLine("Found '{0}' in '{1}' at position {2}", + public static void Main() + { + // + String str = "animal"; + String toFind = "n"; + int index = str.IndexOf("n"); + Console.WriteLine("Found '{0}' in '{1}' at position {2}", toFind, str, index); - // The example displays the following output: - // Found 'n' in 'animal' at position 1 - // - } + // The example displays the following output: + // Found 'n' in 'animal' at position 1 + // + } } From a919ae548e4abde6ec3f4a3cb7fbf2c6fef863ac Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:53:38 -0700 Subject: [PATCH 24/35] fix indentation --- .../system.String.Trim/cs/Trim1.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs index 5a76478b9e2..d6d9624dde9 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim1.cs @@ -2,19 +2,19 @@ public class Example { - public static void Main() - { - // - char[] charsToTrim = { '*', ' ', '\''}; - string banner = "*** Much Ado About Nothing ***"; - string result = banner.Trim(charsToTrim); - Console.WriteLine("Trimmmed\n {0}\nto\n '{1}'", banner, result); + public static void Main() + { + // + char[] charsToTrim = { '*', ' ', '\''}; + string banner = "*** Much Ado About Nothing ***"; + string result = banner.Trim(charsToTrim); + Console.WriteLine("Trimmmed\n {0}\nto\n '{1}'", banner, result); - // The example displays the following output: - // Trimmmed - // *** Much Ado About Nothing *** - // to - // 'Much Ado About Nothing' - // - } + // The example displays the following output: + // Trimmmed + // *** Much Ado About Nothing *** + // to + // 'Much Ado About Nothing' + // + } } From b9cc767b79d4c7ea4ab8fea8e313b5a9b9613195 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:55:04 -0700 Subject: [PATCH 25/35] fix indentation --- .../system.String.Trim/cs/Trim2.cs | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs index e777cba7ab3..61df41a1f9f 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Trim/cs/Trim2.cs @@ -2,33 +2,33 @@ public class Example { - public static void Main() - { - // - Console.Write("Enter your first name: "); - string firstName = Console.ReadLine(); + public static void Main() + { + // + Console.Write("Enter your first name: "); + string firstName = Console.ReadLine(); - Console.Write("Enter your middle name or initial: "); - string middleName = Console.ReadLine(); + Console.Write("Enter your middle name or initial: "); + string middleName = Console.ReadLine(); - Console.Write("Enter your last name: "); - string lastName = Console.ReadLine(); + Console.Write("Enter your last name: "); + string lastName = Console.ReadLine(); - Console.WriteLine(); - Console.WriteLine("You entered '{0}', '{1}', and '{2}'.", + Console.WriteLine(); + Console.WriteLine("You entered '{0}', '{1}', and '{2}'.", firstName, middleName, lastName); - string name = ((firstName.Trim() + " " + middleName.Trim()).Trim() + " " + + string name = ((firstName.Trim() + " " + middleName.Trim()).Trim() + " " + lastName.Trim()).Trim(); - Console.WriteLine("The result is " + name + "."); + Console.WriteLine("The result is " + name + "."); - // The following is possible output from this example: - // Enter your first name: John - // Enter your middle name or initial: - // Enter your last name: Doe - // - // You entered ' John ', '', and ' Doe'. - // The result is John Doe. - // - } + // The following is a possible output from this example: + // Enter your first name: John + // Enter your middle name or initial: + // Enter your last name: Doe + // + // You entered ' John ', '', and ' Doe'. + // The result is John Doe. + // + } } From f904f064e971786c486e4063091df4769bf34821 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:56:12 -0700 Subject: [PATCH 26/35] fix indentation --- .../cs/NullString1.cs | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs index 7f113c45b72..cbeb40830a9 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.string.isnullorempty/cs/NullString1.cs @@ -2,37 +2,39 @@ public class Example { - public static void Main() - { - // - String s = null; + public static void Main() + { + // + String s = null; - Console.WriteLine("The value of the string is '{0}'", s); + Console.WriteLine("The value of the string is '{0}'", s); - try { - Console.WriteLine("String length is {0}", s.Length); - } - catch (NullReferenceException e) { - Console.WriteLine(e.Message); - } + try + { + Console.WriteLine("String length is {0}", s.Length); + } + catch (NullReferenceException e) + { + Console.WriteLine(e.Message); + } - // The example displays the following output: - // The value of the string is '' - // Object reference not set to an instance of an object. - // - } + // The example displays the following output: + // The value of the string is '' + // Object reference not set to an instance of an object. + // + } } public class Empty { - public void Test() - { - // - String s = ""; - Console.WriteLine("The length of '{0}' is {1}.", s, s.Length); - // The example displays the following output: - // The length of '' is 0. - // - } -} + public void Test() + { + // + String s = ""; + Console.WriteLine("The length of '{0}' is {1}.", s, s.Length); + // The example displays the following output: + // The length of '' is 0. + // + } +} From 250cc7546364fb3738da82141748b525ef31c8f5 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:56:51 -0700 Subject: [PATCH 27/35] fix indentation --- .../system.string.replace/cs/replace1.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs index 882e7014d04..847d347b7d1 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace1.cs @@ -2,17 +2,17 @@ public class Example { - public static void Main() - { - // - String s = "aaa"; - Console.WriteLine("The initial string: '{0}'", s); - s = s.Replace("a", "b").Replace("b", "c").Replace("c", "d"); - Console.WriteLine("The final string: '{0}'", s); + public static void Main() + { + // + String s = "aaa"; + Console.WriteLine("The initial string: '{0}'", s); + s = s.Replace("a", "b").Replace("b", "c").Replace("c", "d"); + Console.WriteLine("The final string: '{0}'", s); - // The example displays the following output: - // The initial string: 'aaa' - // The final string: 'ddd' - // - } + // The example displays the following output: + // The initial string: 'aaa' + // The final string: 'ddd' + // + } } From 148affbdc189be74b19634135eb3ff0270eba7e2 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 18:57:31 -0700 Subject: [PATCH 28/35] fix indentation --- .../system.string.replace/cs/replace2.cs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs index 8e84df2fbe5..e7f77c54ca9 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.string.replace/cs/replace2.cs @@ -2,16 +2,17 @@ public class Example { - public static void Main() - { - // - String s = new String('a', 3); - Console.WriteLine("The initial string: '{0}'", s); - s = s.Replace('a', 'b').Replace('b', 'c').Replace('c', 'd'); - Console.WriteLine("The final string: '{0}'", s); - // The example displays the following output: - // The initial string: 'aaa' - // The final string: 'ddd' - // - } + public static void Main() + { + // + String s = new String('a', 3); + Console.WriteLine("The initial string: '{0}'", s); + s = s.Replace('a', 'b').Replace('b', 'c').Replace('c', 'd'); + Console.WriteLine("The final string: '{0}'", s); + + // The example displays the following output: + // The initial string: 'aaa' + // The final string: 'ddd' + // + } } From 570b9bcafb60dac588d729936a7f7541540afb84 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 19:03:23 -0700 Subject: [PATCH 29/35] undo change --- .../system.String.Compare/cs/compare21.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs index 74169dd29ad..d77d9562534 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare21.cs @@ -1,10 +1,10 @@ -using System; +// +using System; public class Example { public static void Main() { - // string s1 = "ani\u00ADmal"; string s2 = "animal"; @@ -13,6 +13,6 @@ public static void Main() // The example displays the following output: // Comparison of 'ani-mal' and 'animal': 0 - // } } +// From ad11363a1c4a1d1cc88426da0f08550b6aab76a2 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 19:05:21 -0700 Subject: [PATCH 30/35] undo change --- .../system.String.Compare/cs/compare22.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs index 04416f6318c..8b5e11dab81 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs @@ -13,6 +13,6 @@ public static void Main() // The example displays the following output: // Comparison of 'ani-mal' and 'animal': 0 - // } } +// From b3216d1ce67f6c1e5186e8dcda0684074f297bb5 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 19:05:55 -0700 Subject: [PATCH 31/35] fix output --- .../system.String.Compare/cs/compare22.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs index 8b5e11dab81..d5dbe4ab31c 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare22.cs @@ -12,7 +12,7 @@ public static void Main() s1, s2, String.Compare(s1, s2, true)); // The example displays the following output: - // Comparison of 'ani-mal' and 'animal': 0 + // Comparison of 'Ani-mal' and 'animal': 0 } } // From 4affeec6aed25fe73e60a966cd93156509255f4e Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 19:07:50 -0700 Subject: [PATCH 32/35] undo change + fix output --- .../system.String.Compare/cs/compare23.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs index 62c390196ae..84a622f0589 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.Compare/cs/compare23.cs @@ -1,11 +1,11 @@ -using System; +// +using System; using System.Globalization; public class Example { public static void Main() { - // string s1 = "Ani\u00ADmal"; string s2 = "animal"; @@ -14,7 +14,7 @@ public static void Main() CultureInfo.InvariantCulture)); // The example displays the following output: - // Comparison of 'ani-mal' and 'animal': 0 - // + // Comparison of 'Ani-mal' and 'animal': 0 } } +// From d730788a32b7a03be1f5b7d39463d6a07e46f7c1 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 19:09:17 -0700 Subject: [PATCH 33/35] undo change --- .../system.String.IndexOf/CS/ignorable21.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs index 2d12038bdcb..36e0ee1abab 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable21.cs @@ -1,10 +1,10 @@ -using System; +// +using System; public class Example { public static void Main() { - // string s1 = "ani\u00ADmal"; string s2 = "animal"; @@ -28,6 +28,6 @@ public static void Main() // 1 // 4 // 3 - // } } +// From 578f12942ca4ce2f3906a2566578f85011dbf41d Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 19:10:18 -0700 Subject: [PATCH 34/35] undo change --- .../system.String.IndexOf/CS/ignorable22.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs index d6aa0d2a1f0..e1180339da9 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable22.cs @@ -1,10 +1,10 @@ -using System; +// +using System; public class Example { public static void Main() { - // string searchString = "\u00ADm"; string s1 = "ani\u00ADmal" ; string s2 = "animal"; @@ -15,6 +15,6 @@ public static void Main() // The example displays the following output: // 4 // 3 - // } } +// From 31f5c6c2b378da5aa4b611b616ad6d96af5bc442 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Thu, 8 Aug 2019 19:12:05 -0700 Subject: [PATCH 35/35] undo change --- .../system.String.IndexOf/CS/ignorable23.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs index 562ad95289d..be4b57bf6f2 100644 --- a/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs +++ b/snippets/csharp/VS_Snippets_CLR_System/system.String.IndexOf/CS/ignorable23.cs @@ -1,10 +1,10 @@ -using System; +// +using System; public class Example { public static void Main() { - // string searchString = "\u00ADm"; string s1 = "ani\u00ADmal" ; string s2 = "animal"; @@ -15,6 +15,6 @@ public static void Main() // The example displays the following output: // 4 // 3 - // } } +//