CSharp examples for Language Basics:Operator
Increasing by 1 using Increment Operator, Decreasing By 1 Using Decrement Operator
using System;//from ww w. j a va 2 s . co m using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { // Input Console.Write("Enter a number: "); string input = Console.ReadLine(); int number = Convert.ToInt32(input); // Increasing by 1 using INCREMENT OPERATOR number++; // same as number = number + 1; Console.WriteLine("Increased by 1: " + number); // Decreasing by 1 using DECREMENT OPERATOR number--; // same as number = number - 1; Console.WriteLine("Back again: " + number); } }