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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions snippets/csharp/VS_Snippets_CLR/string.compare3/CS/comp3.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//<snippet1>
// Sample for String.Compare(String, Int32, String, Int32, Int32)
// Sample for String.Compare(String, Int32, String, Int32, Int32)
using System;

class Sample {
public static void Main() {
//<snippet1>
// 0123456
String str1 = "machine";
String str2 = "device";
Expand All @@ -17,12 +17,13 @@ public static void Main() {
Console.Write("Substring '{0}' in '{1}' is ", str1.Substring(2, 2), str1);
Console.Write("{0} ", str);
Console.WriteLine("substring '{0}' in '{1}'.", str2.Substring(0, 2), str2);

/*
This example produces the following results:

str1 = 'machine', str2 = 'device'
Substring 'ch' in 'machine' is less than substring 'de' in 'device'.
*/
//</snippet1>
}
}
/*
This example produces the following results:

str1 = 'machine', str2 = 'device'
Substring 'ch' in 'machine' is less than substring 'de' in 'device'.
*/
//</snippet1>
27 changes: 14 additions & 13 deletions snippets/csharp/VS_Snippets_CLR/string.compare4/CS/comp4.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//<snippet1>
// Sample for String.Compare(String, Int32, String, Int32, Int32, Boolean)
// Sample for String.Compare(String, Int32, String, Int32, Int32, Boolean)
using System;

class Sample {
public static void Main() {
//<snippet1>
// 0123456
String str1 = "MACHINE";
String str2 = "machine";
Expand All @@ -26,16 +26,17 @@ public static void Main() {
Console.Write("Substring '{0}' in '{1}' is ", str1.Substring(2, 2), str1);
Console.Write("{0} ", str);
Console.WriteLine("substring '{0}' in '{1}'.", str2.Substring(2, 2), str2);
}
}
/*
This example produces the following results:

str1 = 'MACHINE', str2 = 'machine'
Ignore case:
Substring 'CH' in 'MACHINE' is equal to substring 'ch' in 'machine'.
/*
This example produces the following results:

str1 = 'MACHINE', str2 = 'machine'
Ignore case:
Substring 'CH' in 'MACHINE' is equal to substring 'ch' in 'machine'.

Honor case:
Substring 'CH' in 'MACHINE' is greater than substring 'ch' in 'machine'.
*/
//</snippet1>
Honor case:
Substring 'CH' in 'MACHINE' is greater than substring 'ch' in 'machine'.
*/
//</snippet1>
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
// <Snippet1>
using System;
using System.Globalization;

public class Example
{
public static void Main()
{
// <Snippet1>
string string1 = "brother";
string string2 = "Brother";
string relation;
Expand Down Expand Up @@ -53,6 +53,6 @@ public static void Main()
// 'brother' comes before 'Brother'.
// 'brother' is the same as 'Brother'.
// 'brother' comes after 'Brother'.
// </Snippet1>
}
}
// </Snippet1>