8,497
社区成员
发帖
与我相关
我的任务
分享
List<product> listNew = (from s1 in aproduct
join s2 in score
on s1.id equals s2.id
select new product
{
id = s1.id,
score3 =sumScore( s2.score1 , s2.score2,s1.id)
}).ToList();
//将计算逻辑封装成方法 放在查询外边
//此处 建议你修改类 将score3改成double类型 因为除出来的结果会有小数
int sumScore(int score1, int score2,int id)
{
int result = 0;
int temp = score1 + score2;
result = (temp + id) / temp * id;
return result;
}
(from s in slist
let s1 = s.Trim()
where s1 != string.Empty && !s1.StartsWith("//")
let sp = s1.Split(',')
select new G { 编号 = int.Parse(sp[0]), 隶属 = int.Parse(sp[1]), 名称 = sp[2] }).ToList();