Skip to content

How do I convert string to integers?

Oluwaseun Akinrinlola

Asked Jan 5, 2006, 1:10 AM EST1 answer
Share
LinkedInX

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()?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    Hi...

    that will be via Parsing......

    String a = "152";
    int x = Int.Parse(a);

    Good luck....

    0