string less than c# code example
Example 1: c sharp if string equals
string str1 = "Hello";
string str2 = "Hello";
str1 == str2;
str1.Equals(str2);
Example 2: string comparison in c#
SYNTAX:
string.Compare(str1, str2);
RULE:
s1==s2 returns 0
s1>s2 returns 1
s1<s2 returns -1
EXAMPLE:
using System;
public class StringExample{
public static void Main(string[] args){
string s1 = "hello";
string s2 = "hello";
string s3 = "csharp";
Console.WriteLine(string.Compare(s1,s2));
Console.WriteLine(string.Compare(s2,s3));
}
}