c# Tuple新特性
标签:mini max var nim res stat ring orderby 新特性
class Operation
{
internal Tuple FindMinMax(List list)
{
int maximum = int.MinValue, minimum = int.MaxValue;
list.ForEach(n =>
{
minimum = n
maximum = n > maximum ? n : maximum;
});
return Tuple.Create(minimum, maximum);
}
}
使用:
static void Main(string[] args)
{
List numbers = Enumerable.Range(1, 100).OrderBy(x => Guid.NewGuid()).Take(10).ToList();
Operation op = new Operation();
var res = op.FindMinMax(numbers);
var min = res.Item1;
var max = res.Item2;
}
c# Tuple新特性
标签:mini max var nim res stat ring orderby 新特性
原文地址:http://www.cnblogs.com/94cool/p/7645514.html
评论