如何获得在Visual C#中的最大超过2的数字? [英] How to get the maximum of more than 2 numbers in Visual C#?

查看:142
本文介绍了如何获得在Visual C#中的最大超过2的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有五个数字数组和2号的数组。我如何才能找到这些7个号码中最大号码是多少?有没有可以使事情变得更容易的方法?


解决方案

  INT []数组1 = {0,1,5,2,8};
INT []数组2 = {9,4};INT最大= array1.Concat(数组2)。最大();
//最大== 9

I have an array of five numbers and an array of 2 numbers. How would I find out the largest number among these 7 numbers? Is there a method that can make things easier?

解决方案

int[] array1 = { 0, 1, 5, 2, 8 };
int[] array2 = { 9, 4 };

int max = array1.Concat(array2).Max();
// max == 9

这篇关于如何获得在Visual C#中的最大超过2的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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