Vidyalelo
C# Programming · Q57

LINQ (Language

Programming · C# Programming · question 57

Q57

In the following C# code, which query will work according to the set of code? class Program static void Main(string[] args) int[] nums = 1, -2, 3, 0, -4, 5 ; int len = /*_________________ */ Console.WriteLine("The number of positive values in nums: " + len); Console.ReadLine();

A.
from n in nums where n > 0
select n
B.
from n in nums where n > 0
select n.Count()
C.
(from n in nums where n > 0
select n).Count();
Answer
D.
Both "from n in nums where n > 0 select n.Count()" & "(from n in nums where n > 0 select n).Count();"

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board