Examveda

What will be the output of the following C# code snippet?
class Program
    {
        static void Main(string[] args)
        {
 
            int[] nums = { 1, -2, -3, 5 };
            var posNums = from n in nums
                          orderby n descending
                          select n*4 / 2;
            Console.Write("The values in nums: ");
            foreach (int i in posNums) Console.Write(i + " ");
            Console.WriteLine();
            Console.ReadLine();
        }
    }

A. 10 2 -4 -6

B. 5 1 -2 -3

C. 1 5 -2 -3

D. Run time error

Answer: Option A


Join The Discussion

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