Examveda

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        string[] strs = { ".com", ".net", "facebook.com", "google.net", 
                         "test", "netflix.net", "hsNameD.com" };
        var netAddrs = from addr in strs
                       where addr.Length > 4 && addr.EndsWith(".net",
                       StringComparison.Ordinal)
                       select addr;
        foreach (var str in netAddrs) Console.WriteLine(str);
        Console.ReadLine();
    }
}

A. Compile time error

B. Run time error

C. facebook.com
netflix.net
google.net

D. google.net
netflix.net

Answer: Option D


Join The Discussion

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