products with exact values "Apple", "Banana", "Cherry"prices with exact values 1.2, 0.5, 2.0productPrices to store the zipped pairsforeach loop with variables product and price to iterate over productPrices"Apple: $1.2"products with exact values "Apple", "Banana", "Cherry"prices with exact values 1.2, 0.5, 2.0productPrices to store the zipped pairsforeach loop with variables product and price to iterate over productPrices"Apple: $1.2"products with these exact values: "Apple", "Banana", "Cherry". Also create a list of doubles called prices with these exact values: 1.2, 0.5, 2.0.Use List<string> for products and List<double> for prices. Initialize them with the exact values.
productPrices that uses products.Zip(prices, (product, price) => (product, price)) to combine the two lists into pairs.Use var productPrices = products.Zip(prices, (product, price) => (product, price)); to combine the lists.
foreach loop with variables product and price to iterate over productPrices.Use foreach (var (product, price) in productPrices) to loop through the pairs.
foreach loop, write Console.WriteLine($"{product}: ${price}"); to print each product and its price.Use Console.WriteLine($"{product}: ${price}"); inside the loop to print each pair.
What does the Zip method do in C#?
Choose the best description.
Which of the following is the correct syntax to use Zip on two lists list1 and list2 to sum their elements?
var result = list1.Zip(list2, (a, b) => ? );
list1.Zip(list2, (a, b) => a + b) correctly sums paired elements.What is the output of this C# code?
var numbers = new[] {1, 2, 3};
var words = new[] {"one", "two"};
var zipped = numbers.Zip(words, (n, w) => $"{n}:{w}");
foreach(var item in zipped) Console.Write(item + " ");Identify the error in this code snippet using Zip:
var a = new[] {1, 2, 3};
var b = new[] {4, 5};
var result = a.Zip(b, (x, y) => x + y).ToList();
Console.WriteLine(result[2]);You have two lists:
var keys = new[] {"a", "b", "c", "d"};
var values = new[] {1, 2, 3};Using Zip, how can you create a dictionary that pairs keys and values only for matching positions?
Pass the test and this pattern moves unknown