Please see this code snippet and tell me what to do
using System;
class me
{
public static void Main()
{
string one;
int a;
one=Console.ReadLine();
a=(int)one;
Console.WriteLine(a);
}
}
the code gives an error. I want to convert it to an integer without using Convert.ToInt32() method. I am trying to convert it explicitly. Is there no other way apart from Convert.ToInt32()?
How do I convert string to integers?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
abdullah115 pointsPosted Jan 5, 2006, 11:22 AM EST
Hi...
that will be via Parsing......
String a = "152";
int x = Int.Parse(a);
Good luck....