在C#.net中询问linq [英] asking anout linq in c#.net
问题描述
Dictionary<string,double> dic = new Dictionary<string, double>();
dic.Add("Stuend 1",80);
dic.Add("Stuend 2", 70);
dic.Add("Stuend 3", 40.7);
dic.Add("Stuend 4", 50);
dic.Add("Stuend 5",22);
dic.Add("Stuend 6", 100);
我需要获得分数的学生密钥名称最少.
我可以知道如何与Linq一起使用.
I want to need Student Key name who get the mark is minimum.
May i know how to wiite with Linq.
推荐答案
尝试一下:
Try this:
var maxValue = dic[dic.Keys.Max()];
请参考一些示例链接:
以下方法在序列的每个元素上调用转换函数,并返回最大Int32
值:
Enumerable.Max< tsource>方法(IEnumerable< tsource>,Func< tsource>) [ ^ ]
此方法以可为空的Double
值序列返回最大值.可枚举.Max方法(IEnumerable< nullable>< double>>) [ ^ ]
另请参阅:
可枚举 [原型可枚举的max()方法 [ max()
公共 [ ^ ]
Please refer some links for examples:
The following method invokes a transform function on each element of a sequence and returns the maximum Int32
value:
Enumerable.Max<tsource> Method (IEnumerable<tsource>, Func<tsource,>)[^]
This method returns the maximum value in a sequence of nullable Double
values.Enumerable.Max Method (IEnumerable<nullable><double>>)[^]
Also refer:
Enumerable[^]
Prototype Enumerable max() Method[^]
max()
public[^]
由于这听起来像是作业,因此建议您从这里开始frm:Enumerable.Max方法 [
Since this sounds like homework, I''d suggest that you start for example frm here: Enumerable.Max Method [^]
这篇关于在C#.net中询问linq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!