Progress Monitor for IdealProgrammer.com
Take Swift, Intelligent, Massive, Planned, Loving, Effective (S.I.M.P.L.E.) Action to Transform Self into Ideal
Skip Repetitive Navigational Links
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console
Please login
C-Sharp strComp Example Syntax - C# String Function - Sample Code
Description:
Illustrates the C# Syntax for strComp.
Example Class Main:
using System; public class clsStrComp { public void Main() { //**************************************************************************************** // Note: Compare is the c# equivalent for vb.net strComp // Example #1: StrComp(string1,string2,comparemethod) - returns integer // Returns -1, 0, or 1, based on the result of a string comparison. // -1 String1 sorts ahead of String2 // 0 String1 is equal to String2 // 1 String1 sorts after String2 // comparemethod - Optional. Specifies the type of string comparison. If Compare is omitted, // the Option Compare setting determines the compare method //**************************************************************************************** Console.WriteLine("Example #1: StrComp(string1,string2,comparemethod) "); string strString1 = "XYZ"; string strString2 = "xyz"; // Return Uppercase Console.WriteLine(string.Compare(strString1, strString2, true).ToString()); //Returns 0 Console.WriteLine(string.Compare(strString1, strString2, false).ToString()); //Returns 1 strString2 = "ABC"; Console.WriteLine(string.Compare(strString1, strString2, false).ToString()); //Returns 1 //write blank line to make output easier to read Console.WriteLine(); //Prevent console from closing before you press enter Console.ReadLine(); } }
Example Class Program:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namestrComp CSharp_Syntax { class Program { static void Main(string[] args) { clsstrComp mystrComp = new clsstrComp(); mystrComp.Main(); } } }
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console