top of page

Prefix and Postfix increments in C#

Admin

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