Sau đây là mảng của chúng tôi -
double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7}; Để lấy phần tử đầu tiên, hãy sử dụng phương thức First ().
myArr.AsQueryable().First();
Hãy cho chúng tôi xem mã hoàn chỉnh -
Ví dụ
using System;
using System.Linq;
using System.Collections.Generic;
class Demo {
static void Main() {
double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};
double res = myArr.AsQueryable().First();
Console.WriteLine(res);
}
} Đầu ra
20.5