Convert.ToDouble Method in C#


To convert a specified value to a double-precision floating-point number, use Convert.ToDouble() method.

The following is our long value −

long[] val = { 340, -200};

Now convert it to Double.

double result;
result = Convert.ToDouble(val);

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      long[] val = { 340, -200};
      double result;
      // long to double
      foreach (long number in val) {
         result = Convert.ToDouble(number);
         Console.WriteLine("Converted {0} value to {1}",number, result);
      }
   }
}

Output

Converted 340 value to 340
Converted -200 value to -200

Updated on: 23-Jun-2020

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements