Question 16


Question

Multiple Choice

You are developing an applicaton that will convert data into multple output formats.
The applicaton includes the following code. (Line numbers are included for reference only.)

You are developing a code segment that will produce tab-delimited output. All output routnes implement the following interface:

You need to minimize the completon tme of the GetOutput() method.
Which code segment should you insert at line 06?

  • A. string output = null;
    for (int i = 1; iterator.MoveNext(); i++)
    {
    output = string.Concat(output, iterator.Current, suffix(i));
    }
    return output;
  • B. var output = new StringBuilder();
    for (int i = 1; iterator.MoveNext(); i++)
    {
    output.Append(iterator.Current);
    output.Append(suffix(i));
    }
    return output.ToString();
  • C. string output = null;
    for (int i = 1; iterator.MoveNext(); i++)
    {
    output = output + iterator.Current + suffix(i);
    }
    return output.ToString();
  • D. string output = null;
    for (int i = 1; iterator.MoveNext(); i++)
    {
    output += iterator.Current + suffix(i);
    }
    return output;

Answer:

B