Mono Class Library: System.Int64 Overview | Members

System.Int64.Parse Method

Returns the specified string converted to a long value.

public static long Parse (string s)

Parameters

s
A string containing the value to convert. The string is interpreted using the System.Globalization.NumberStyles.Integer style.

Returns

The long value obtained from s.

Exceptions

TypeReason
ArgumentNullExceptions is a null reference.
FormatExceptions is not in the correct style.
OverflowExceptions represents a number greater than long.MaxValue or less than long.MinValue.

Remarks

This version of long.Parse(string) is equivalent to long.Parse(string) (s, System.Globalization.NumberStyles.Integer, null).

The string s is parsed using the formatting information in a System.Globalization.NumberFormatInfo initialized for the current system culture.

Note: For more information, see System.Globalization.NumberFormatInfo.CurrentInfo.

Example

This example demonstrates parsing a string to a long.

C# Example

using System;
public class Int64ParseClass {
  public static void Main() {
    string str = "  100   ";
    Console.WriteLine("String: \"{0}\" <Int64> {1}",str,Int64.Parse(str));
  }
}

The output is

String: " 100 " <Int64> 100

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0