exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 54 discussion

Actual exam question from Microsoft's 70-483
Question #: 54
Topic #: 1
[All 70-483 Questions]

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))
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Int32.TryParse - Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded.
Incorrect Answers:
B, C: These will throwan exception when user enters non-integer value.
D: This is exactly the opposite what we want to achieve.
References: http://msdn.microsoft.com/en-us/library/f02979c7.aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
noussa
4 years, 5 months ago
A is good just missing 32 for int means it should be like this: If (!Int32.TryParse(sLine, out number))
upvoted 1 times
aliwiyao
4 years, 5 months ago
int qnd Int32 sq,e
upvoted 1 times
...
...
Lifebek
5 years, 4 months ago
Shouln't correct answer be D here?
upvoted 1 times
whtvr
5 years, 4 months ago
If (Int32.TryParse(sLine, out number)) if the sLine is not a number, the TryParse will return "false", so in this case, the code will go for the "else" which is wrong, that's why A is correct, with the negation
upvoted 9 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...