Advertisement

Responsive Advertisement

II.2-Modulus Operator (%),II.3- Increment and Decrement Operators (++,- -)

 

II.2-Modulus Operator (%)

Of course, you might want to calculate the remainder from an integer division, not throw it away. For that, C# provides a special operator, modulus (%), to retrieve the remainder. For example, the statement 17%4 returns 1 (the remainder after integer division).

II.3- Increment and Decrement Operators (++,- -)

You’ll often find yourself needing to manipulate the value in a variable, and then store that result back in the original variable. Suppose, for example, that you have a variable inventory, which you use to keep track of the quantity of widgets you have in your warehouse. You wouldn’t want to have to create new variables every time inventory increases or decreases; you want the current value to always be available in inventory. C# provides several operators for just these kinds of calculations.












Post a Comment

0 Comments