nerdexam
Microsoft

70-515 · Question #158

You are implementing an ASP.NET page. Client-side script requires data. Your application includes a class named Person with a Name property of type string. The code-behind file of the page includes…

The correct answer is A. JsonValue = json.Serialize(people.Select(p => p.Name)). See the full explanation below for the reasoning.

Question

You are implementing an ASP.NET page. Client-side script requires data. Your application includes a class named Person with a Name property of type string. The code-behind file of the page includes the following code segment. public string JsonValue; List<Person> people = GetPeopleList(); JavaScriptSerializer json = new JavaScriptSerializer(); You need to use the JavaScriptSerializer class to serialize only the Name property of each item in the people list. Which code segment should you use?

Options

  • AJsonValue = json.Serialize(people.Select(p => p.Name));
  • Bvar names = from person in people
  • CJsonValue = json.Serialize(people.SelectMany(
  • Dvar names = from person in people

How the community answered

(43 responses)
  • A
    77% (33)
  • B
    7% (3)
  • C
    5% (2)
  • D
    12% (5)

Community Discussion

No community discussion yet for this question.

Full 70-515 Practice