First() 메서드를 사용하여 배열에서 첫 번째 요소를 가져옵니다.
먼저 배열을 설정합니다.
int[] arr = {20, 40, 60, 80 , 100}; 이제 Queryable First() 메서드를 사용하여 첫 번째 요소를 반환합니다.
arr.AsQueryable().First();
다음은 전체 예입니다.
예시
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
int[] arr = {20, 40, 60, 80 , 100};
// getting the first element
int res = arr.AsQueryable().First();
Console.WriteLine(res);
}
} 출력
20