

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- Python Increment and Decrement Operators
- Increment and decrement operators in Java
- Increment and Decrement Operators in C#
- Increment ++ and decrement -- Operators in C++
- Increment and Decrement Operators in Python?
- PHP Increment/Decrement Operators
- What are the restrictions on increment and decrement operators in java?
- Interesting facts about Increment and Decrement operators in Java
- Why avoid increment (“++”) and decrement (“--”) operators in JavaScript?
- Increment ++ and Decrement -- Operator Overloading in C++
- Pre-increment (or pre-decrement) in C
- Write a C program to demonstrate post increment and pre increment operators
- What are C operators and Punctuators?
- What are JavaScript Operators
- What are operators in JavaScript?
Advertisements