如何在C#中返回在数组中找到的最大数量 [英] How to returns the maximum number found in the array in c#

查看:225
本文介绍了如何在C#中返回在数组中找到的最大数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#语言的新手.谷歌搜索后,我找不到合适的答案,请给我一些解决方案.

I am new to C# language. After googling I am not able to find appropriate answer please give me some solution to do this.

我想编写一个方法,该方法接收整数数组作为参数并返回在c#中数组中找到的最大数目"

"I want to write a method that receives as parameter an array of integers and returns the maximum number found in the array in c#"

推荐答案

尝试IEnumerable.Max().

Try IEnumerable.Max().

//remember to add "System.Linq" to your usings
int maxVal = yourArray.Max();

这篇关于如何在C#中返回在数组中找到的最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆