Count 메서드는 시퀀스의 요소 수를 반환합니다.
먼저 배열을 설정하겠습니다.
string[] arr = { "Java", "C++", "Python"}; 이제 Count() 메서드를 사용하여 배열 요소를 계산합니다.
arr.AsQueryable().Count();
다음은 완전한 예입니다.
예시
using System;
using System.Linq;
using System.Collections.Generic;
class Demo {
static void Main() {
string[] arr = { "Java", "C++", "Python"};
int arr_count = arr.AsQueryable().Count();
Console.WriteLine("Count of arrays: {0}", arr_count);
}
} 출력
Count of arrays: 3