Examveda

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        string[] strs = {"alpha", "beta", "gamma"};
        var chrs = from str in strs
                   let chrArray = str.ToCharArray()
                   from ch in chrArray
                   orderby ch
                   select ch;
        Console.WriteLine("The individual characters in sorted order:");
        foreach (char c in chrs) 
        Console.Write(c + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

A. a a l h a b g m m a p e t a

B. a a a a a b e g h l m m p t

C. a g h l m m p t a a a a b e

D. Run time error

Answer: Option B


Join The Discussion

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