本文整理汇总了C#中Common.List.Max方法的典型用法代码示例。如果您正苦于以下问题:C# List.Max方法的具体用法?C# List.Max怎么用?C# List.Max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.Max方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main()
{
int num = Helpers.ValidateInputAsInt("How many numbers you would like to enter: ");
List<double> numbers = new List<double>();
// Fill array with numbers
for (int i = 0; i < num; i++)
{
numbers.Add(Helpers.ValidateInputAsDouble("Enter value " + (i + 1) + ": "));
}
// Use of List methods
Console.WriteLine("Minimal number is : {0}", numbers.Min());
Console.WriteLine("Maximal number is : {0}", numbers.Max());
Console.WriteLine("Sum number is : {0}", numbers.Sum());
Console.WriteLine("Average number is : {0}", numbers.Average());
}
示例2: Map
/// <summary>
/// 功能:显示用户电站地图
/// 描述:根据电站id获取电站的经度纬度
/// 作者:张月
/// 时间:2011年3月12日 16:38:08
/// </summary>
/// <returns>电站id</returns>
public ActionResult Map()
{
double[] point = { 1960, 980, 490, 245, 120, 60, 30, 15, 7.5, 3.7, 1.90 };
IList<Plant> plants = UserUtil.getCurUser().plants;
IList<double> values = new List<double>();
if (plants.Count > 1)
{
for (int i = 1; i < plants.Count; i++)
{
values.Add(GetDistance(plants[0].latitude, plants[0].longitude, plants[i].latitude, plants[i].longitude));
}
}
double max = values.Count > 0 ? values.Max() : 0;
ViewData["point"] = 2;
for (int i = point.Length - 1; i >= 0; i--)
{
if (point[i] > max / 8)
{
ViewData["point"] = i;
break;
}
}
ViewData["plant"] = plants;
return View();
}
示例3: UpdateRechargeRecord
//.........这里部分代码省略.........
sysAccount.sad_cFlowType = record.rcr_cRechargeType;
sysAccount.sad_cOpt = record.rcr_cLast;
sysAccount.sad_cRecordID = Guid.NewGuid();
sysAccount.sad_dOptTime = DateTime.Now;
listSysAccountInfos.Add(sysAccount);
}
}
#endregion
if (listUserAccountInfos.Count > 0)
{
//插入由充值记录产生的账户记录
listToInsertAccountDetail.AddRange(listUserAccountInfos);
listToInsertSysDetail.AddRange(listSysAccountInfos);
}
//查找用户是否含有预充值记录
decimal fAdvance = decimal.Zero;
#region 获取用户透支金额
List<RechargeRecord_rcr> listAdvance = db.RechargeRecord_rcr.Where(x =>
x.rcr_cUserID == listRechargeRecords[0].rcr_cUserID
&& x.rcr_cRechargeType == Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString()
).ToList();
if (listAdvance != null && listAdvance.Count > 0)
{
fAdvance = listAdvance.OrderByDescending(x => x.rcr_dRechargeTime).FirstOrDefault().rcr_fRechargeMoney;
}
#endregion
decimal fCurrentBalance = decimal.Zero;
//获取本次充值的最后卡余额
decimal fCardBalance = listRechargeRecords.Max(x => x.rcr_fBalance);
if (Math.Abs(fPreCostRecharge) >= 0 && listRechargeRecords.Count > 0)//若存在需要支付预付款的金额,则进行平数处理
{
//记录欠款总额
decimal fSumPreCost = decimal.Zero;
//若预付款还款值大于0,则更新被支付的未结算预付款记录
#region 结算预付款项
List<PreConsumeRecord_pcs> listPreCost = db.PreConsumeRecord_pcs.Where(x =>
x.pcs_lIsSettled == false //需为未支付金额
&& x.pcs_cAccountID == account.cua_cRecordID //需要账户对口
&& x.pcs_cUserID == listRechargeRecords[0].rcr_cUserID //需要对口人员ID
).ToList();
//筛选预付款的消费类型
listPreCost = filterRecord_CanComputePreCost(listPreCost);
fSumPreCost = listPreCost.Sum(x => x.pcs_fCost);
if (Math.Abs(fPreCostRecharge) < Math.Abs(fSumPreCost))
{
db.Transaction.Rollback();
db.Connection.Close();
rvInfo.messageText = "支付额不足以支付待结算的预付款。";
return rvInfo;
}
List<CardUserAccountDetail_cuad> listPreUserCost = new List<CardUserAccountDetail_cuad>();
List<SystemAccountDetail_sad> listPreSysIncome = new List<SystemAccountDetail_sad>();
foreach (PreConsumeRecord_pcs preItem in listPreCost)
{
preItem.pcs_lIsSettled = true;
preItem.pcs_dSettleTime = DateTime.Now;
示例4: UpperBound
public double UpperBound()
{
int n = this.coefficients.Count-1;
List<double> candidates = new List<double>(n){1};
for (int i = n; i > 0; i--) {
candidates.Add(Math.Abs((coefficients[i] / coefficients[0]) * n));
}
return candidates.Max();
}