using system;using system.collections.generic;using system.linq;using system.text; Namespace _6. Operator's mathematical operator { class program { static void main (String[] args) { // Add, subtract, multiply , divide and withdraw operators { int intVar1 = 53, intvar2 = 6; float floatVar = 52.54F; double doubleVar = 23.21; console.writeline ("{0} + {1} = {2}", intvar1, floatvar, Intvar1 + floatvar); console.writeline ("{0} - {1} = {2}", intvar1, intvar2, INTVAR1&NBSP;-&NBSP;INTVAR2); console.writeline ("{0} * {1} = {2}", intvar1, intvar2, INTVAR1&NBSP;*&NBSP;INTVAR2); console.writeline ("{0} * {1} = {2}", intvar2, doublevar, Intvar2 * doublevar); console.wRiteline ("{0} / {1} = {2}", &NBSP;INTVAR1,&NBSP;INTVAR2,&NBSP;INTVAR1&NBSP;/&NBSP;INTVAR2); Console.WriteLine ("{0} / {1} = {2}", intvar2, doublevar, intvar2 / doublevar); console.writeline ("{0} % {1} = {2}", intvar1, intvar2, intvar1 % &NBSP;INTVAR2); console.writeline ("{0} % {1} = {2}", intvar1, doublevar, intvar1 % doublevar); } // positive and negative operators { int var = -1; console.writeline ("var: {0}", var); // The positive sign operator has no effect on the result. Console.WriteLine ("+var: {0}", +var); console.writeline ("-var: {0}", -var); } // string Join operator (+) { string stringVal1 = "hello, "; string stringVal2 = "world!"; string stringresult = stringVal1 + stringVal2; console.writeline ("stringresult: {0}", stringresult); } // self-increment, decrement operator { // 1. put the operator before the operand, the operand is affected by the operator before any other calculations are made. // 2. After the operator is placed behind the operand, the operand is affected by the operator after the completion of the evaluation of the expression. int var1 = 5, var2 = 3; console.writeline ("Var1: {0}, ++var1: {1}, var1: {2}", var1, &NBSP;++VAR1,&NBSP;VAR1);   Console.WriteLine ("Var1: {0}, --var1: {1}, var1: {2}", var1, --var1, VAR1); Console.WriteLine ("Var2: {0}, var2++: {1}, var2: {2}", var2, var2++, VAR2); Console.WriteLine ("Var2: {0}, var2--: {1}, var2: {2}", var2, var2--, VAR2); } /** * Math Assignment Operators * its syntax format: * <variable> += <expression> ==> < variable> = <variable> + (<expression>) * <variable> -= <expression> = => <variable> = <variable> - (<expression>) * <variable> *= < expression> ==> <variable> = <variable> * (<expression>) * <variable> /= <expression> ==> <variable> = <variable> / ( <expression>) * <variable> %= <expression> ==> <variable> = <variable> % (< expression>) * The * += operator can also be applied to string joins. */ console.readkey (); } }}
This article is from the "MK IT Life" blog, so be sure to keep this source http://vikxiao.blog.51cto.com/9189404/1585748
Vi. arithmetic appended mathematical operators