Which code segment should you add at line 19?

You are developing an application that includes the following 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?
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))

Answer: A

Explanation:

Incorrect:

Not B, not C: These will throw exception when user enters non-integer value.

Not D: This is exactly the opposite what we want to achieve.

Int32.TryParse – Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. http://msdn.microsoft.com/en-us/library/f02979c7.aspx

Latest 70-483 Dumps Valid Version with 288 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments