PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

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 JsonValue As String
Dim people As List(Of Person) = GetPeopleList()
Dim json As JavaScriptSerializer = New JavaScriptSerializer()
You need to use the JavaScriptSerializer class to serialize only the value of the Name property of
each item in the people list. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
JsonValue = json.Serialize(people.Select(Function(p) p.Name))

B.
Dim names = From person In people Select person
JsonValue = “{” & json.Serialize(names) & “}”

C.
JsonValue = json.Serialize(people.SelectMany(
Function(p) p.Name.AsEnumerable()))

D.
Dim names = From person In people Select person
JsonValue = json.Serialize(names)

Explanation:


Leave a Reply