প্রথমত, একটি ক্রম সেট করুন।
List<int> myList = new List<int> { 1, 2, 3, 4 ,5}; এখন Queryable Sum() পদ্ধতি ব্যবহার করে যোগফল খুঁজুন।
myList.AsQueryable().Sum();
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
List<int> myList = new List<int> { 1, 2, 3, 4 ,5};
Console.WriteLine("Sum of elements in a list...");
foreach (int res in myList) {
Console.WriteLine(res);
}
int sum = myList.AsQueryable().Sum();
Console.WriteLine("Sum = {0}", sum);
}
} আউটপুট
Sum of elements in a list... 1 2 3 4 5 Sum = 15