Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Decimal type in C#
The decimal type is a value type and has the plus, minus, multiply and divide operators.
Firstly, set two decimal values ?
decimal d1 = 5.8M; decimal d2 = 3.2M;
To add decimals ?
d1 = d1 + d2;
Let us see an example to add two decimal values ?
Example
using System;
using System.Linq;
class Demo {
static void Main() {
decimal d1 = 5.8M;
decimal d2 = 3.2M;
d1 = d1 + d2;
Console.WriteLine(d1);
}
}
Output
9.0
Advertisements
