Case Sensitivity of the == Operator

Rumman Ansari   Software Engineer   2023-10-17   422 Share
☰ Table of Contents

Table of Content:


Case Sensitivity of the == Operator

The == and != operators are case insensitive in X++, but are case sensitive in C#, as is illustrated by the following example.

X++

C#

Comments

"HELLO" == "hello"

True in X++.

"HELLO" == "hello"

False in C#.

Different case comparisons between X++ and C#.


internal final class CodePractice
{
   public static void main(Args _args)
   {
       setPrefix("Output");       
       CodePractice::stringCompare("abc", "abc");
       CodePractice::stringCompare("abc", "ABC");
       CodePractice::stringCompare("ABC", "abc");
       CodePractice::stringCompare("abc", "aaa");
       CodePractice::stringCompare("aaa", "abc");      
   }
 
   public static void stringCompare(str _str1, str _str2){
       int result = (_str1 == _str2);
       Info(strFmt("%1 - %2 Result %3 ", _str1, _str2, result));
   }
 
}

Output:


abc - abc Result 1
abc - ABC Result 1
ABC - abc Result 1
abc - aaa Result 0
aaa - abc Result 0