adplus-dvertising
frame-decoration

Question

Select the output for given code snippet:
class Program
{
    static void Main(string[] args)
    {
        int[] nums = {1};
        var posNums = from n in nums
                      wheres n > 0 
                     select Math.Max(78, 9);
        Console.Write("The largest values in nums: ");
        foreach (int i in posNums) Console.Write(i + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

a.

Code runs successfully prints nothing

b.

Run time error

c.

Code runs successfully prints required output

d.

Compile time error

Posted under LINQ C# programming

Answer: (c).Code runs successfully prints required output

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Select the output for given code snippet: