Wednesday 16 November 2011

Convert String to Long using C#


Int64.Parse Method converts the string representation of a number to its 64-bit signed integer equivalent. This can be used to convert the string to long as shown below
public long Convert2Long(String Str1)
{
try
{
long LngString = Int64.Parse(Str1);
return LngString;
}
catch (System.FormatException)
{
Console.WriteLine("Parameter is not in required format");
return -1;
}
}

No comments:

Post a Comment