X++, C# Comparison: Operators [AX 2012]
Updated: October 21, 2011
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#.
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:
But in X++ these two operators are for statements, not for expressions. Therefore the following lines generate compile errors in X++:

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:

/ 
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#. 
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#. 
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.