PdfPrep.com

How should you complete the code?

DRAG DROP

You have a class named Product that has a property named Name.

You have the following code.

You need to get the Name property of oneProduct.

How should you complete the code? To answer, drag the appropriate code elements to the correct targets. Each code element 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.

NOTE: Each correct selection is worth one point.

Answer:

string productName = oneProduct.GetType().GetProperties().First(prop => prop.Name == “Name”).GetValue(oneProduct).ToString();

Exit mobile version