Converts the string representation of a number to its 64-bit signed integer equivalent. If the conversion failed the return value is 0. - CSharp System

CSharp examples for System:String Convert

Description

Converts the string representation of a number to its 64-bit signed integer equivalent. If the conversion failed the return value is 0.

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Security.Cryptography;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using System;/*from  w  w w.  jav  a 2s  . c o  m*/

public class Main{
        /// <summary>
        /// Converts the string representation of a number to its 64-bit signed integer
        /// equivalent. If the conversion failed the return value is 0.
        /// </summary>
        /// <returns>System.Int64</returns>
        public static long ToLong(this string input)
        {
            long longValue;
            long.TryParse(input, out longValue);
            return longValue;
        }
}

Related Tutorials