top of page

Prefix and Postfix increments in C#

  • Admin
  • Jun 23, 2024
  • 1 min read

Example at belows show prefix and postfix increments in C#.



int x = 5;


Console.WriteLine("x: {0}", x); //Output x: 5


Console.WriteLine("x++: {0}", x++); // Output x: 5


Console.WriteLine("x: {0}", x); // Output x: 6 



int x = 5;


Console.WriteLine("x: {0}", x); // Output x: 5


Console.WriteLine("++x: {0}", ++x); // Output x: 6


Console.WriteLine("x: {0}", x); // Output x: 6 




Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

© 2023

 
bottom of page