I have an array of five numbers and an array of two numbers. How can I find out the largest number from these 7 numbers? Is there a way to make things easier?
int[] array1 = { 0, 1, 5, 2, 8 }; int[] array2 = { 9, 4 }; int max = array1.Concat(array2).Max(); // max == 9
You can try
decimal max = Math.Max(arr1.Max(), arr2.Max());
:
Math.Max(Math.Max(a,b), c)//on and on for the number of numbers you have
LINQ:
int[] arr1; int[] arr2; int highest = (from number in new List<int>(arr1).AddRange(arr2) orderby number descending select number).First();
3.5, Linq:
using System.Linq; var values = new int[] { 1,2,3,4,5 }; var maxValue = values.Max();
Source: https://habr.com/ru/post/1724155/More articles:Creating a SQL Server 2000 Database Using SQL Server 2008 - sqlJQuery Event.target issue in ie7 - jqueryPHP inverse to matrix - phpFactor Analysis in R - rSymfony table widget - symfony1Private methods using .NET reflection. What for? - reflectionPHP - UPLOAD_ERR_NO_TMP_DIR - phpJava swing. How to wait for other Jframes - javaHow to get the final result in the viewed results? - sqlDoes asp.net have a function for checking email addresses? - emailAll Articles