Operator <> (Not equal)
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpNotEqual
- Last revised: 2016-03-13
Compares two expressions for inequality
Syntax
declare operator <> ( byref lhs as byte, byref rhs as byte ) as integer
declare operator <> ( byref lhs as ubyte, byref rhs as ubyte ) as integer
declare operator <> ( byref lhs as short, byref rhs as short ) as integer
declare operator <> ( byref lhs as ushort, byref rhs as ushort ) as integer
declare operator <> ( byref lhs as integer, byref rhs as integer ) as integer
declare operator <> ( byref lhs as uinteger, byref rhs as uinteger ) as integer
declare operator <> ( byref lhs as longint, byref rhs as longint ) as integer
declare operator <> ( byref lhs as ulongint, byref rhs as ulongint ) as integer
declare operator <> ( byref lhs as single, byref rhs as single ) as integer
declare operator <> ( byref lhs as double, byref rhs as double ) as integer
declare operator <> ( byref lhs as string, byref rhs as string ) as integer
declare operator <> ( byref lhs as zstring, byref rhs as zstring ) as integer
declare operator <> ( byref lhs as wstring, byref rhs as wstring ) as integer
declare operator <> ( byref lhs as T, byref rhs as T ) as integer
declare operator <> ( byref lhs as boolean, byref rhs as boolean ) as booleanUsage
` result = lhs <> rhs
`
Parameters
lhs
The left-hand side expression to compare to.
rhs
The right-hand side expression to compare to.
T
Any pointer type.
Return Value
Returns negative one (-1) if expressions are not equal, or zero (0) if equal.
Description
Operator <> (Not equal) is a binary operator that compares two expressions for inequality and returns the result - a boolean value mainly in the form of an Integer: negative one (-1) for true and zero (0) for false. Only if the left and right-hand side types are both Boolean, the return type is also Boolean. The arguments are not modified in any way.
This operator can be overloaded to accept user-defined types as well.
Examples
start GeSHi
Dim As String a = "hello", b = "world"
Dim As Integer i = 10, j = i
If (a <> b) Then
Print a & " does not equal " & b
End If
If (i <> j) Then
Print "error: " & i & " does not equal " & j
End Ifend GeSHi
Operator = (Equal) is complement to Operator <> (Not equal), and is functionally identical when combined with Operator Not (Bit-wise Complement).
start GeSHi
If (69 <> 420) Then Print "(69 <> 420) is true."
If Not (69 = 420) Then Print "not (69 = 420) is true."end GeSHi
Dialect Differences
- In the -lang qb dialect, this operator cannot be overloaded.
Differences from QB
- none
See also
Operator =(Equal)
Back to DocToc