UiPath RPA Associate (UiRPA) — Question 34
Which expression should be used to return the first four characters from a String variable called StrVar?
Answer options
- A. StrVar.Substring(0, 4)
- B. StrVar.Substring(1, 4)
- C. StrVar.Substring(1, 5)
- D. StrVar.Substring(4)
Correct answer: A
Explanation
The correct answer is A, as StrVar.Substring(0, 4) starts at index 0 and retrieves four characters. Options B and C both start at index 1, which omits the first character, and option D starts at index 4, which returns characters beyond the first four.