c# string equals ignore case
string.Equals(val, "astringvalue", StringComparison.OrdinalIgnoreCase)
c# string equals ignore case
string.Equals(val, "astringvalue", StringComparison.OrdinalIgnoreCase)
c sharp if string equals
// There are two ways to check if 2 strings are the same:
string str1 = "Hello";
string str2 = "Hello";
// The first is using double equals sign ==
str1 == str2; // Output: true
// The second is using the 'Equals()' function
str1.Equals(str2); // Output: true
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)); //0
Console.WriteLine(string.Compare(s2,s3)); //1
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us