PrepAway - Latest Free Exam Questions & Answers

Which code segment should you add at line 19?

You are developing an application that includes thefollowing code segment. (Line numbers are
included for reference only.)

You need to ensure that the application accepts only integer input and prompts the user each time
non-integer input is entered.
Which code segment should you add at line 19?

PrepAway - Latest Free Exam Questions & Answers

A.
If (!int.TryParse{sLine, out number))

B.
If ((number = Int32.Parse(sLine)) = = Single.NaN)

C.
If ((number = int.Parse (sLine)) > Int32.MaxValue)

D.
If (Int32.TryParse(sLine, out number))

3 Comments on “Which code segment should you add at line 19?

    1. Ashraf says:

      In the first glance I chose D too, but the questions states that we need to prompt the user when the result is false, which makes A is the right answer due to (!), so in A it says if the tryparse result is false we will take action to notify the user and probably will return or set default value or re-ask for a new value, if not (If it’s a number), then number variable has the value and the code proceed.




      3



      0

Leave a Reply