Listnumbers = new List { 4, 9, 12, 15, 20 }; int sum = numbers.Sum();
ListThis code creates a list of double values representing prices, and then calculates the total cost by summing all items in the list and rounding it to two decimal places using the Math.Round method. These code examples use the System.Windows.Documents namespace, which is part of the WPF (Windows Presentation Foundation) library in C#.prices = new List { 12.99, 23.50, 8.75, 15.00 }; double total = Math.Round(prices.Sum(), 2);