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 correctlocations 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.)
Select and Place:

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 correctlocations 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.)
Select and Place:

Answer:

Explanation:
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 *


Swapnil

Swapnil

Ans : from where orderby ascending select .. Confirmed

decimal[] loanAmounts = { 303m, 1000m, 85579m,501.51m,1200m,400m,22m };
IEnumerable loanQuery =
from amount in loanAmounts
where amount % 2 == 0
orderby amount ascending
select amount;

foreach (var item in loanQuery)
{
Console.WriteLine(item);

}
Console.ReadLine();