Convert.ToInt64 Method in C#


Convert a specified value to a 64-bit signed integer using Convert.ToInt64 Method.

Let us take a double value.

double doubleNum = 193.834;

Now, convert it to Int64 i.e. long.

long res;
res = Convert.ToInt32(doubleNum);

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      double doubleNum = 193.834;
      long res;
      res = Convert.ToInt32(doubleNum);
      Console.WriteLine("Converted {0} to {1}", doubleNum, res);
   }
}

Output

Converted 193.834 to 194

Updated on: 23-Jun-2020

400 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements