maffle

maffle

  • NA
  • 14
  • 0

try-and-catch

Nov 25 2006 5:14 AM

Visual Studio 2005, C# using command prompt when running the program

static
double getQA()

{try

{double qA = Convert.ToDouble(Console.ReadLine());

return qA * 0.10;}

catch

{Console.WriteLine("Invalid Input!");}}

this at first works fine until i added the try-and-catch! it produces an error
'not all code paths return a value'. where's the problem?

-----------------------------------------------------------------------
and also, i want to ask how will i repeat the program for another user.
i ask like this.. Try Again? [Y/N]:
i dnt know what to do when the user presses yes.
im just new to C#. i study through tutorials but i can't find these things so i hope you understand
tnx in advance


Answers (10)