C# Convert ToInt64(Object, IFormatProvider)
Description
Convert ToInt64(Object, IFormatProvider)
converts
the value of the specified object to a 64-bit signed integer, using the specified
culture-specific formatting information.
Syntax
Convert.ToInt64(Object, IFormatProvider)
has the following syntax.
public static long ToInt64(
Object value,
IFormatProvider provider
)
Parameters
Convert.ToInt64(Object, IFormatProvider)
has the following parameters.
value
- An object that implements the IConvertible interface.provider
- An object that supplies culture-specific formatting information.
Returns
Convert.ToInt64(Object, IFormatProvider)
method returns A 64-bit signed integer that is equivalent to value, or zero if value is null.
Example
using System;/* ww w. j a va 2 s . c o m*/
using System.Globalization;
class MainClass
{
public static void Main( )
{
NumberFormatInfo provider = new NumberFormatInfo();
provider.NegativeSign = "neg ";
provider.PositiveSign = "pos ";
provider.NumberDecimalSeparator = ".";
provider.NumberGroupSeparator = ",";
provider.NumberGroupSizes = new int[ ] { 3 };
provider.NumberNegativePattern = 0;
Console.WriteLine( Convert.ToInt64((object) "12345" ));
Console.WriteLine( Convert.ToInt64((object) "12345", provider ) );
}
}
The code above generates the following result.