Provided that you can use .NET 3.5 (or newer) and LINQ, try
int sum = arr.Sum();
More Related Contents:
- Difference between List and array when initiating [closed]
- How do I remove duplicates from a C# array?
- Using C# to check if string contains a string in string array
- Merging two arrays in .NET
- Is there a performance impact when calling ToList()?
- Convert json to a C# array?
- How do I cast int to enum in C#?
- How do I sort a two-dimensional (rectangular) array in C#?
- How to copy part of an array to another array in C#?
- How do you get the width and height of a multi-dimensional array?
- What is the default value of a member in an array?
- C# hashcode for array of ints
- Redim Preserve in C#?
- .Net Data structures: ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary — Speed, memory, and when to use each? [closed]
- C# quickest way to shift array
- How do I find duplicates in an array and display how many times they occurred?
- How to create byte array from HttpPostedFile
- Initializing an Array of Structs in C#
- C# Append byte array to existing file
- Wildcard equivalent in C# generics
- How to get the most common value in an Int array? (C#)
- How to get all subsets of an array?
- Casting a byte array to a managed structure
- C# params object[] strange behavior
- What is the default value of the nullable type “int?” (including question mark)?
- Casting array to IEnumerable
- How to get random values from array in C# [duplicate]
- Are immutable arrays possible in .NET?
- How to convert byte array to any type
- Force garbage collection of arrays, C#