C# 程式以顯示第一個陣列元素
以下是我們的陣列 −
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
廣告
資料結構
網路
關係型資料庫
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式語言
C++
C#
MongoDB
MySQL
Javascript
PHP