Double Datatype in C# Programming Language

Rumman Ansari   Software Engineer   2022-07-19   6051 Share
☰ Table of Contents

Table of Content:


Double

A double data type is used to work with decimals. In this case, the numbers are whole numbers like 10.11, 20.22 or 30.33. In C#, the datatype is denoted by the keyword "Double". Below is an example of this datatype.

In our example, we will define a double variable called num. We will then assign a Double value to the variable and then display it accordingly.

 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoApplication
{
 class Program
 { 
  static void Main(string[] args) 
  {
   double num=30.33;
   Console.Write(num); 
   
   Console.ReadKey();
  }
 }
}

Code Explanation:-

  1. The double data type is specified to declare a double type variable called num. The variable is then assigned a value of 30.33.
  2. Finally the console.write function is used to display the number to the console.

If the above code is entered properly and the program is executed successfully, the following output will be displayed.

Output:

30.33

From the output, you can clearly see that the double variable called num was displayed in the console