Return multiple values: Difference between revisions

Added C# solution.
(Added C# solution.)
Line 32:
Output:
<PRE>The greatest number is 987 , the smallest -10 !</PRE>
 
=={{header|C sharp}}==
 
<lang c sharp>using System;
using System.Collections.Generic;
using System.Linq;
 
namespace ReturnMultipleValues
{
internal class Program
{
static void Main()
{
var minMax = MinMaxNum(new[] {4, 51, 1, -3, 3, 6, 8, 26, 2, 4});
 
int min = minMax.Item1;
int max = minMax.Item2;
 
Console.WriteLine("Min: {0}\nMax: {1}", min, max);
}
 
static Tuple<int,int> MinMaxNum(IEnumerable<int> nums)
{
var sortedNums = (from num in nums orderby num ascending select num).ToArray();
return new Tuple<int, int>(sortedNums.First(), sortedNums.Last());
}
}
}</lang>
 
'''Output'''
<pre>Min: -3
Max: 51</pre>
 
=={{header|Common Lisp}}==