csharp calculate sum of list

Code Example - csharp calculate sum of list

                
                        double total = myList.Sum(item => item.Amount);
                    
                
 

add all elements in a list csharp

                        
                                using System.Collections.Generic;
using System.Linq;

List<int> intList = new List<int>(){1, 2, 3, 4};
int sum = intList.Aggregate((x, y) => x + y);
                            
                        
 

csharp sum of list

                        
                                using System.Linq;
int my_sum = my_int_list.Sum();
                            
                        
 

list sum csharp

                        
                                int total = monValues.Sum(x => Convert.ToInt32(x));