Udostępnij za pośrednictwem


X++, C# Comparison: Operators

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

This topic compares the operators between Microsoft Dynamics AX X++ and C#.

Assignment Operators

The following table displays the differences between the assignment operators in X++ and C#.

X++ and C#

Differences

=

In X++ this operator causes an implicit conversion whenever a loss of precision might occur, such for an assignment from an int64 to an int. But in C# the assignment causes a compile error.

+=

and

-=

The only difference is that in C# these operators are also used in delegate manipulation.

++

and

--

These are the increment and decrement operators in both languages. The following line is identical in both languages:

  • ++myInteger;

But in X++ these two operators are for statements, not for expressions. Therefore the following lines generate compile errors in X++:

  • myStr = int2str(++myInteger);

  • myIntA = myIntBB++;

Arithmetic Operators

The following table lists the arithmetic operators.

X++ and C#

Differences

*

As the multiplication operator, there are no differences.

Note

The asterisk is also used in the SQL statements that are part of the X++ language. In these SQL statements the asterisk can also be one of the following:

  • A wildcard indicating that all the columns should be returned.

  • A wildcard for characters in a string that is used on a like clause.

For more information, see Relational Operators.

/

The division operator is the same in X++ and C#.

MOD

For modulo operations, the only difference is that the % symbol is used in C#.

+

The addition operator is the same in X++ and C#. The plus sign is also used for string concatenation.

This operator adds numbers and concatenates strings in both languages.

-

The subtraction operator is the same in X++ and C#.

Bitwise Operators

The following table compares the bitwise operators between X++ and C#.

X++ and C#

Differences

<<

The left shift operator is the same in X++ and C#.

>>

The right shift operator is the same in X++ and C#.

~

The bitwise NOT operator is the same in X++ and C#.

&

The binary AND operator is the same in X++ and C#.

^

The binary XOR operator is the same in X++ and C#.

|

The binary OR operator is the same in X++ and C#.

Relational Operators

The following relational operators are the same in X++ and C#:

  • ==

  • >=

  • <=

  • >

  • <

  • !=

  • &&

  • ||

  • !

  • ? :

See also

X++, C# Comparisons

Operators

Expression Operators: Is and As for Inheritance

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.