UiPath Advanced RPA Developer (UiARD) — Question 38
You have two string variables called Name and City. You want to construct a new sentence that includes the values from the following variables:
My name is <Name> and I live in <City>
Which expression will provide the required output?
Answer options
- A. String.Format("My name is {0} and I live in {1}", Name, City)
- B. String.Format("My name is {0} and I live in {1}", "Name", "City")
- C. String.Format("My name is {1} and I live in {2)", "Name", "City")
- D. String.Format("My name is {1} and I live in {2}", Name, City)
Correct answer: A
Explanation
The correct answer A is right because it uses the proper placeholders {0} and {1} to reference the variables Name and City, respectively. Option B incorrectly uses the string literals 'Name' and 'City' instead of the variable values. Option C has a syntax error with the closing parenthesis, and option D uses incorrect placeholders which do not match the variable indices.