
- 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
What are increment (++) and decrement (--) operators in C#?
Increment Operators
To increment a value in C#, you can use the increment operators i.e. Pre-Increment and Post-Increment Operators.
The following is an example −
Example
using System; class Demo { static void Main() { int a = 250; Console.WriteLine(a); a++; Console.WriteLine(a); ++a; Console.WriteLine(a); int b = 0; b = a++; Console.WriteLine(b); Console.WriteLine(a); b = ++a; Console.WriteLine(b); Console.WriteLine(a); } }
Decrement Operators
To decrement a value in C#, you can use the decrement operators i.e. Pre-Decrement and Post-Decrement Operators.
The following is an example −
Example
using System; class Demo { static void Main() { int a = 250; Console.WriteLine(a); a--; Console.WriteLine(a); --a; Console.WriteLine(a); int b = 0; b = a--; Console.WriteLine(b); Console.WriteLine(a); b = --a; Console.WriteLine(b); Console.WriteLine(a); } }
- 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++
- Increment and Decrement Operators in C#
- PHP Increment/Decrement Operators
- What are the restrictions on increment and decrement operators in java?
- Why avoid increment (“++”) and decrement (“--”) operators in JavaScript?
- Interesting facts about 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