Long.parse method in C#


To convert a string to a long, use the Long.parse method in C# −

Firstly, set a string −

string str = "7864646475767";

Now, convert it to long −

long.Parse(str);

Here is the complete code −

Example

 Live Demo

using System;
using System.Linq;
class Demo {
   static void Main() {
      string str = "7864646475767";
      long res = long.Parse(str);
      Console.WriteLine(res);
   }
}

Output

7864646475767

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 22-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements