本文整理汇总了C#中System.Collections.Dictionary.Aggregate方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.Aggregate方法的具体用法?C# Dictionary.Aggregate怎么用?C# Dictionary.Aggregate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.Aggregate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HtmlElement
/// <summary>
/// Builds the element with a list of attributes
/// </summary>
/// <param name="el">The element</param>
/// <param name="attributes">A dictionary of attributes to add to the element</param>
public HtmlElement(String el, Dictionary<String, String> attributes )
{
var attrs = attributes.Aggregate("", (current, item) => current + (item.Key + "='" + item.Value + "' " ));
this.elementStart = "<" + el + " " + attrs + ">";
this.elementEnd = "</" + el + ">";
this.el = el;
}
示例2: DetermineDataType
/// <summary>
/// Returns the type that is used most often in a range of cells.
/// </summary>
/// <returns>The predominant <c>Type</c> in the range of cells.</returns>
public static Type DetermineDataType(Range excelCells)
{
IDictionary<Type, int> typeCounts = new Dictionary<Type, int> ();
foreach (Range cell in excelCells) {
if (cell.Value == null) {
logger.Info ("A null value was encoutered in Cell: {0}{1}",
cell.Row,
cell.Column);
} else {
Type cellType = cell.Value.GetType ();
if (typeCounts.ContainsKey (cellType)) {
typeCounts [cellType] += 1;
} else {
typeCounts.Add (cellType, 1);
}
}
}
if (typeCounts.Count == 0)
throw new ArgumentException ("All cells were empty. Can not proceed");
Type maxUsedType = typeCounts.Aggregate ((l, r) => l.Value > r.Value ? l : r).Key;
return maxUsedType;
}
示例3: GetRelativeOrientation2
private RelativeOrientation GetRelativeOrientation2(IPolycurve pFoundLineAsPolyCurve, IPolycurve inPolycurve)
{
//iRelativeOrientation == 1 --> closest points are original TO and found TO
//iRelativeOrientation == 2 --> closest points are original TO and found FROM
//iRelativeOrientation == 3 --> closest points are original FROM and found TO
//iRelativeOrientation == 4 --> closest points are original FROM and found FROM
Dictionary<int, double> dictSort2GetShortest = new Dictionary<int, double>();
dictSort2GetShortest.Add(1, ((IProximityOperator)pFoundLineAsPolyCurve.ToPoint).ReturnDistance(inPolycurve.ToPoint));
dictSort2GetShortest.Add(2, ((IProximityOperator)pFoundLineAsPolyCurve.FromPoint).ReturnDistance(inPolycurve.ToPoint));
dictSort2GetShortest.Add(3, ((IProximityOperator)pFoundLineAsPolyCurve.ToPoint).ReturnDistance(inPolycurve.FromPoint));
dictSort2GetShortest.Add(4, ((IProximityOperator)pFoundLineAsPolyCurve.FromPoint).ReturnDistance(inPolycurve.FromPoint));
return (RelativeOrientation)dictSort2GetShortest.Aggregate((l, r) => l.Value < r.Value ? l : r).Key;
}
示例4: PrintDictionary
public static void PrintDictionary(Dictionary<string, string> dict)
{
var pS = dict.Aggregate("\n",
(current, variable) => current + (variable.Key + "=" + variable.Value + "\n"));
Log.Debug(pS);
}