DRAG DROP
You are developing an ASP.NET Web API action method.
The action method must return the following JSON in the message body.
{ ” Name “:” Fabrikam”, “Vendor Id”: 9823, “Items”: [“Apples”, “Oranges”] }
You need to return an anonymous object that is serialized to JSON.
What should you do? (To answer, drag the appropriate code segments to the correct
location or locations in the answer area. Each code segment may be used once, more than
once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Explanation:
block1: return new
block2: “Fabrikam”, VendorNumer=98,23
block3: new list<string>{“Apples”, “oranges”}
this question is duplicate , and first time the answer different to the second time , please which answer is the correct ?
return new {
Name = “Fabrikam”, VendorNumber = 9823, // notice the datatypes string/int
Items = new List { “Apples”, “Oranges” } // notice the array/list
};
the JSON output will be something like this:
{
“Name”: “Fabrikam”,
“VendorNumber”: 9823,
“Items”: [“Apples”, “Oranges”]
}
This is the order
return new {
Name = “Fabrikam”, VendorNumber = 9823,
Items = new List { “Apples”, “Oranges” }
};
That is the end of this report. Here you will locate some web-sites that we feel youll enjoy, just click the hyperlinks.