以下是我们的数组-
double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};要获取第一个元素,请使用First()方法。
myArr.AsQueryable().First();
让我们看完整的代码-
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);
}
}输出结果
20.5