Show/Hide Toolbars

XSharp

X# uses the following Logical operators:

 

         

Operator

Example

Meaning

<

x < y

less than (true if x is less than y).
See below for string comparisons

<=

x <= y

less than or equal to (true if x is less than or equal to y).
See below for string comparisons

>

x > y

greater than (true if x is greater than y).
See below for string comparisons

>=

x >= y

greater than or equals to (true if x is greater than or equal to y).
See below for string comparisons

=

x = y

equality.
Note that there is a difference between = and == for strings only. See below

==

x == y

exact equality.
Note that there is a difference between = and == for strings only. See below

<>, #, !=

x <> y, x # y, x != y

not equal
Note that for strings this follows the same rules as the single = operator.

$

x $ y

Is substring of. Returns true if the first string is a substring of the second (case sensitive !)

IS

x IS y

Type compatibility. Returns true if the evaluated left operand can be cast to the type specified in the right operand (a static type).

ASTYPE

x ASTYPE y

Type conversion. Returns the left operand cast to the type specified by the right operand (a static type), but as returns null where (T)x would throw an exception.

String comparisons

The '=' and '==' operators behave differently for strings, and the behavior of the single equals also depends on a runtime setting.

 

If you call SetExact(FALSE) then ‘=’ equates the characters up to the length of the string on the right-hand side of the operator ignoring the remaining characters on the left. This is the default setting. If you call SetExact(TRUE) then = and == have the same meaning for strings.

The <, <=, > and >= operators for strings have a behavior that depends on a compiler option and a runtime setting. The -vo13 compiler option 'compatible string comparions' tells the compiler that it needs to use a runtime function for string comparisons. The behavior of this runtime function depends on the setting of SetCollation(). There are 4 possible values for SetCollation():

Setting

Description

Clipper

This setting will convert both strings to OEM strings using the current DOS codepage. After that the strings will be compared using the string comparison / weight  tables that are defined with SetNatDLL(). The default comparison uses a wight based on the byte number. Other comparisons available are for example GERMAN, DUTCH, FRENCH, RUSSION, SPANISH, SLOV852 etc.
This setting should be used if your application needs to share files with CLIPPER programs.

Windows

This setting will convert both strings to ANSI using the current ANSI codepage. After that the strings will be compared using the normal windows ANSI CompareString() code. This setting should be used when your application shares files with VO programs

Unicode

This setting will NOT convert strings and will do a normal Unicode string comparison using the String.Compare() method from the .Net

Ordinal

This setting will NOT convert strings and will do a normal Ordinal string comparison using the String.CompareOrdinal() method  from the .Net. This is the fastest.

The >= and <= operators for strings also take into account the setting for SetExact(). The 'equalness' of the 2 strings is determined by the same rules as the '=' operator.