Consider the following code snippet:

static void Main(string[] args)
        {
            string[] fruitsList = { "Grapes", "Apple", "Gooseberry", "Blueberry", "Apricot", "Guava", "Banana" };
            // LINQ query to be written here
            foreach (var item in fruitsResult)
            {
                Console.WriteLine(item.Key);
                foreach (String str in item)
                    Console.WriteLine(str);
                Console.WriteLine();
            }
        }

Identify the suitable LINQ query to be written inside the Main() method, so that it results in the following output?

a. var fruitsResult = from fruits in fruitsList group fruits by fruits.Substring(0, 1) into fruitGroups orderby fruitGroups.Key select fruitGroups;

b. var fruitsResult = from fruits in fruitsList group fruits by fruits.Substring(0, 1) into fruitGroups orderby fruitGroups select fruitGroups;

c. var fruitsResult = from fruits in fruitsList group fruits by fruits.Substring(0, 1) into fruitGroups select fruitGroups;

d. var fruitsResult = from fruits in fruitsList group fruits by fruits.Substring(0, 1) into fruitGroups orderby fruitGroups.Key descending select fruitGroups;

Option a

Option b

Option c

Option d

Verified Answer
Correct Option - a

To get all Advanced CSharp Programming Assessment Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in