Linq LongCount 메서드를 사용하여 요소 수를 가져옵니다.
다음은 우리의 문자열 배열입니다 -
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