C# 程序,查找数组中的最大元素
声明一个数组 −
int[] arr = { 20, 50, -35, 25, 60 };现在要从一个数组中获得最大的元素,可以使用 Max() 方法 −
arr.Max());
这是完整的代码 −
示例
using System;
using System.Linq;
class Demo {
static void Main() {
int[] arr = { 20, 50, -35, 25, 60 };
Console.WriteLine(arr.Max());
}
}输出
60
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP