Examveda

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        int[] nums = { 16,  9, 25};
        var posNums = from n in nums
                      where n > 0 
                      select Math.Sqrt(n);
 
        Console.Write("The positive values in nums: ");
        foreach (int i in posNums) Console.Write(i + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

A. Code runs successfully prints nothing

B. Code runs successfully prints required output

C. Run time error

D. Compile time error

Answer: Option B


Join The Discussion

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