Coverting string to int32
-
Just started C# and the compiler i am using is VS 7.0.When i try to convert a string literal to a integer my compiler is giving me problems.I have three books and i have tried all the examples on the book but they dont work.
using System; class Hello { public static void Main(string[] args) { string s1 = "123"; int num = s1.ToInt32; } }
Error:C:\Documents and Settings\KARANSANDHU\My Documents\Visual Studio Projects\ConsoleApplication1\Class1.cs(8): 'string' does not contain a definition for 'ToInt32' -
Just started C# and the compiler i am using is VS 7.0.When i try to convert a string literal to a integer my compiler is giving me problems.I have three books and i have tried all the examples on the book but they dont work.
using System; class Hello { public static void Main(string[] args) { string s1 = "123"; int num = s1.ToInt32; } }
Error:C:\Documents and Settings\KARANSANDHU\My Documents\Visual Studio Projects\ConsoleApplication1\Class1.cs(8): 'string' does not contain a definition for 'ToInt32'You can try one of following:
int num = Int32.Parse(s1);
int num = Convert.ToInt32(s1);i'm only pointer to myself