[英]How to retrieve second item of HashSet<Tuple<string, int>>
I've a HashSet<Tuple<string, int>>
In the second item I've numbers (1,18,5,46). 我有一个HashSet<Tuple<string, int>>
在第二项中,我有数字(1,18,5,46)。
I'd like to get biggest number of in these items. 我想从这些物品中获取最多的数量。
I'm new in programming so please forgive me for question. 我是编程方面的新手,请原谅我的问题。
I've just found a way and want to share: int max = students.Max(kvp => kvp.Item2);
我刚刚找到了一种方法,想分享一下: int max = students.Max(kvp => kvp.Item2);
You can do this 你可以这样做
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
var students = new List<Tuple<string, int>>();
students.Add(new Tuple<string, int>("test", 10));
students.Add(new Tuple<string, int>("test", 10));
Console.Write(students.Max(t => t.Item2));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.