Converting string to int

  • Thread starter Thread starter whos_bally
  • Start date Start date
W

whos_bally

Guest
Hi guys, I'm still learning the basics.

I wrote a program not too long ago for strings that would get 2 values for 2 variables using one local variable.

I tried to use this method with integers but I'm finding it difficult to understand how to convert the string to an int.

Any help is appreciated,

thank you!


using System;

namespace Test_Environment
{
class Program
{
static void Main(string[] args)
{
int a, b;
a = getInt("number (1)");
b = getInt("number (2)");

}//end main


static int getInt(int number)
{
Console.Write("Enter a whole" + number + " : ");
return Console.Read();
}

}//end class
}//end namespace

Continue reading...
 
Back
Top