Javatpoint Logo
Javatpoint Logo

LINQ sum () Function

In LINQ sum() function is used to calculate the sum of the items in collections/lists.

Following is the syntax to define the LINQ sum function in C#, to sum up, the items on the list.

Syntax of the LINQ Sum function in C#

From the above syntax, we are summing up the items in the "Num" list using the LINQ Sum function.

Now, we will see the complete example of using the LINQ Sum () function to sum up the items from the collections/list in C# applications.

In the above example, we used the sum function to calculate the sum of the elements in the array list "Num."

When we execute the above example, we get the result, as shown below:

LINQ sum () Function

We can use the sum () function in LINQ to sum up the items in the collection/list, which is based on our requirement.






Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA