[英]How do I use “or” (|) operator in C# “object.equals”
var controllingContext = _context.Inventaris.Include(i => i.Artkl).Include(i => i.Status).Where(x => x.StatusId.Equals(stat[0] | stat[1]));
I am trying to add an or operator in C# to the object.equals method this was working while I didn't have the or operator in there and it was just checking for 1 item but now I added the or operator and it doesn't work anymore.我正在尝试将 C# 中的 or 运算符添加到 object.equals 方法中,当我没有 or 运算符并且它只是检查 1 项但现在我添加了 or 运算符但它没有工作了。 Any help would be greatly appreciated任何帮助将不胜感激
If I understood correctly, you want to filter StatusId
equals stat[0]
or stat[1]
.如果我理解正确,您想过滤StatusId
等于stat[0]
或stat[1]
。 If so you just need to use OR( ||
) operator as following:如果是这样,您只需要使用 OR( ||
) 运算符,如下所示:
.Where(x => x.StatusId.Equals(stat[0]) || x.StatusId.Equals(stat[1]));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.