Tuesday, July 28, 2009

How to convert string into integer in C#?

I have string which is "123", I want to convert it into int64, so I can use it in my SQL query,please help


Thanks

How to convert string into integer in C#?
Converting Strings to Numerals





In C# string datatypes can be converted into numeric ones by employing the Parse method of Int64 class. The following C# Snippet demonstrates a method of converting the string datatype into numeric one...





convnumeric.cs


==============





using System;





class myclass


{


static void Main()


{


string mynum = "44";


long myint = Int64.Parse(mynum);





Console.WriteLine("the output of the Parse Method is integer {0}", myint);


}


}





_____________________________________





http://msdn2.microsoft.com/en-us/library...





Int64.Parse() Method:





Converts the string representation of a number to its 64-bit signed integer equivalent








______________________
Reply:long num = Convert.ToInt64("123");


No comments:

Post a Comment