jaguRita

jaguRita

  • NA
  • 40
  • 0

Check for an Integer Value-Without Exception

Aug 10 2007 2:52 AM
Hello all,
I want to multiply a number by itself,and the number must be Integer.A program, when i get the input number as a string it wont take it as the input n it will show an error "You are not entered Integer,try with some other number".(Without use of exceptions),Is there any possiblity?
i have written one code.But it shows an exception at run time.
int number=int.parse(console.ReadLine());
if (number <= int.MaxValue && number >= int.MinValue)
{
Console.Write("\n Enter the number :");
number *= number;
Console.WriteLine(number);
}
else
{
Console.WriteLine("You are not entered Integer,try with some other number");
}
Whats wrong with my code?How will i write the code only it will accept Integers not an decimal or string.
or Some Clues to do it.I will find out the way.
As am learner i want to know the things.
Thanks.

Answers (2)