ConvertToInt64 Method (String, Int32) |
Converts the string representation of a number in a specified base to an equivalent 64-bit signed integer.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static long ToInt64(
string value,
int fromBase
)
Parameters
- value
- Type: SystemString
A string that contains the number to convert. - fromBase
- Type: SystemInt32
The base of the number in value, which must be 2, 8, 10, or 16.
Return Value
Type:
Int64A 64-bit signed integer that is equivalent to the number in
value, or 0 (zero) if
value is null.
Exceptions Exception | Condition |
---|
ArgumentException | fromBase is not 2, 8, 10, or 16. -or-value, which represents a non-base 10 signed number, is prefixed with a negative sign. |
FormatException | value contains a character that is not a valid digit in the base specified by fromBase. The exception message indicates that there are no digits to convert if the first character in value is invalid; otherwise, the message indicates that value contains invalid trailing characters. |
OverflowException | value, which represents a non-base 10 signed number, is prefixed with a negative sign.-or-value represents a number that is less than MinValue or greater than MaxValue. |
See Also