Linq查询&vs &&

时间:2019-10-30 02:49:26

标签: c# linq logical-operators

我看到了&处于linq条件的代码

 var highestApplicationStatus = (from status in ctx.ApplicationStatuses.Where(o => o.ApplicationId == Application.ApplicationId & o.IsDeleted == false & o.StatusDate != null).OrderByDescending(o => o.ApplicationStatusType.DisplayOrder) select status).FirstOrDefault();

我用&&

重写了它
  var highestApplicationStatus = (from status in ctx.ApplicationStatuses.Where(o => o.ApplicationId == Application.ApplicationId && o.IsDeleted == false && o.StatusDate != null).OrderByDescending(o => o.ApplicationStatusType.DisplayOrder) select status).FirstOrDefault();

发布时出现了一个错误,有人问我有关此更改的信息。我的理解是&&用于逻辑“与”,而&&用于按位运算。一名团队成员建议,Linq Environment中的&/ &&相同。有人可以解释差异

0 个答案:

没有答案