C#可查询LongCount方法
使用LinqLongCount方法获取元素计数。
以下是我们的字符串数组-
string[] emp = { "Jack", "Mark"};
现在,使用LongCount()方法。
emp.AsQueryable().LongCount();
这是完整的代码。
示例
using System; using System.Collections.Generic; using System.Linq; class Demo { static void Main() { string[] emp = { "Jack", "Mark"}; long res = emp.AsQueryable().LongCount(); Console.WriteLine("{0} employees in the Department", res); } }
输出结果
2 employees in the Department