Using the Increment and Decrement Unary Operators - CSharp Language Basics

CSharp examples for Language Basics:Operator

Description

Using the Increment and Decrement Unary Operators

Demo Code

class MainClass/*from w  ww . jav a 2s.c o  m*/
{
   static void Main()
   {
      int Val1 = 0;
      int Val2 = 0;

      System.Console.WriteLine("Val1 = {0}  Val2 = {1}", Val1, Val2);

      System.Console.WriteLine("Val1 (Pre) = {0}  Val2 = (Post) {1}", ++Val1, Val2++);

      System.Console.WriteLine("Val1 (Pre) = {0}  Val2 = (Post) {1}", ++Val1, Val2++);

      System.Console.WriteLine("Val1 (Pre) = {0}  Val2 = (Post) {1}", ++Val1, Val2++);
   }
}

Result


Related Tutorials