Examveda

In the following C# code, what does the output represent?
class Program
{
    static void Main(string[] args)
    {
        int[] nums = { 1, -2, 3, 0, -4, 5 };
        var posNums = from n in nums
                      where n > 0
                      select n;
        int len = posNums.Count();
        Console.WriteLine(len);
        Console.ReadLine();
    }
}

A. Execution of code with nothing being printed

B. Execution of code with printing all numbers

C. Execution of code with counting total numbers greater than zero

D. Run time error

Answer: Option C


Join The Discussion

Related Questions on LINQ (Language Integrated Query) in C Sharp