G
gh
Hi every Body ..
in C# if I wont the user to Input a Number I write the
code:
// ... the 1st way for int
String Number;
int X;
Console.Write("Enter A Number:");
Number = Console.ReadLine();
X = Convert.ToInt32(Number);
..
..
and if i wont to Enter a Boolian Value I will write the
code
String BOOL;
char CBOOL;
bool x;
Console.Write("Enter a Bool Value t/f");
BOOL = Console.readLine();
CBOOL = Convert.ToChar(BOOL); // from string to char
if ((CBOOL == 't')||(CBOOL == 'T')) // if the input if
true
{x = true ;}
else if ((CBOOL == 'f')||(CBOOL == 'F')) // if the input
if false
{x = false;}
else{Console.Write("Error ... Not Valid Input");} // if
nither True nor False
..
...
SO , ... is there a method so it Read the Interger or
bool directly with out the use of string and then the
conversion ..?
..
in C# if I wont the user to Input a Number I write the
code:
// ... the 1st way for int
String Number;
int X;
Console.Write("Enter A Number:");
Number = Console.ReadLine();
X = Convert.ToInt32(Number);
..
..
and if i wont to Enter a Boolian Value I will write the
code
String BOOL;
char CBOOL;
bool x;
Console.Write("Enter a Bool Value t/f");
BOOL = Console.readLine();
CBOOL = Convert.ToChar(BOOL); // from string to char
if ((CBOOL == 't')||(CBOOL == 'T')) // if the input if
true
{x = true ;}
else if ((CBOOL == 'f')||(CBOOL == 'F')) // if the input
if false
{x = false;}
else{Console.Write("Error ... Not Valid Input");} // if
nither True nor False
..
...
SO , ... is there a method so it Read the Interger or
bool directly with out the use of string and then the
conversion ..?
..