
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Increment and Decrement Operators in C#
Increment operator increases integer value by one i.e.
int a = 10; a++; ++a;
Decrement operator decreases integer value by one i.e.
int a = 20; a--; --a;
The following is an example demonstrating increment operator −
Example
using System; class Program { static void Main() { int a, b; a = 10; Console.WriteLine(++a); Console.WriteLine(a++); b = a; Console.WriteLine(a); Console.WriteLine(b); } }
Output
11 11 12 12
The following is an example demonstrating decrement operator −
int a, b; a = 10; // displaying decrement operator result Console.WriteLine(--a); Console.WriteLine(a--); b = a; Console.WriteLine(a); Console.WriteLine(b);
- Related Articles
- Python Increment and Decrement Operators
- Increment and decrement operators in Java
- Increment and Decrement Operators in Python?
- Increment ++ and decrement -- Operators in C++
- PHP Increment/Decrement Operators
- Why avoid increment (“++”) and decrement (“--”) operators in JavaScript?
- What are increment (++) and decrement (--) operators in C#?
- Interesting facts about Increment and Decrement operators in Java
- What are the restrictions on increment and decrement operators in java?
- Increment ++ and Decrement -- Operator Overloading in C++
- Pre-increment (or pre-decrement) in C
- Increment Negative and Decrement Positive Numbers by 1 in an Array in Java
- Write a C program to demonstrate post increment and pre increment operators
- Count of suffix increment/decrement operations to construct a given array in C++
- Create increment decrement plus minus buttons programmatically for HTML input type number in JavaScript

Advertisements