How should you complete the relevant code?

DRAG DROP
You are developing an application by using C#. The application includes an array of decimal
values named loanAmounts. You are developing a LINQ query to return the values from the
array.
The query must return decimal values that are evenly divisible by two. The values must be
sorted from the lowest value to the highest value.
You need to ensure that the query correctly returns the decimal values.
How should you complete the relevant code? (To answer, drag the appropriate code
segments to the correct 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.)

DRAG DROP
You are developing an application by using C#. The application includes an array of decimal
values named loanAmounts. You are developing a LINQ query to return the values from the
array.
The query must return decimal values that are evenly divisible by two. The values must be
sorted from the lowest value to the highest value.
You need to ensure that the query correctly returns the decimal values.
How should you complete the relevant code? (To answer, drag the appropriate code
segments to the correct 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.)

Answer: See the explanation.

Explanation:
Box 1: from
Box 2: where
Box 3: orderby
Box 4: ascending
Box 5: select

Note: In a query expression, the orderby clause causes the returned sequence or
subsequence (group) to be sorted in either ascending or descending order.
Examples:

// Query for ascending sort.
IEnumerable<string> sortAscendingQuery =
from fruit in fruits
orderby fruit //"ascending" is default
select fruit;
// Query for descending sort.
IEnumerable<string> sortDescendingQuery =
from w in fruits
orderby w descending
select w;



Leave a Reply 1

Your email address will not be published. Required fields are marked *


MarcoJacob

MarcoJacob

from amount in loanAmounts
where amount % 2 == 0
orderby amount ascending
select amount;