C# Queryable Min 方法
使用 C# 中的 Min() 方法從序列中獲取最小值。
以下是我們的列表。
List<long> list = new List<long> { 1, 2, 3, 4, 5, 6 };現在,使用 Queryable Min() 方法獲取最小元素。
list.AsQueryable().Min();
示例
using System;
using System.Collections.Generic;
using System.Linq;
class Demo {
static void Main() {
List<long> list = new List<long> { 1, 2, 3, 4, 5, 6 };
foreach(long ele in list) {
Console.WriteLine(ele);
}
// getting lowest element
long min_num = list.AsQueryable().Min();
Console.WriteLine("Smallest number = {0}", mix_num);
}
}
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP