嗨,我有一个ICollection:
var x = test.MyList.Where(c => c.MyId == 1);
想获得第一个结果或使用Where子句在implements属性中查找结果,例如:
library(ggplot2)
group = c("gr1","gr1","gr1","gr1","gr1","gr1","gr1","gr1","gr1","gr1","gr2","gr2","gr2","gr2","gr2","gr2","gr2","gr2","gr2","gr2","gr3","gr3","gr3","gr3","gr3","gr3","gr3","gr3","gr3","gr3")
pos = c(1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10)
color = c(2,2,2,2,3,3,2,2,3,2,1,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,1,1,2,2)
df = data.frame(group, pos, color)
ggplot(data = df, aes(x = group, y = pos)) + geom_tile(aes(fill = color))
但是我的对象没有列出Where或FirstOrDefault
等方法答案 0 :(得分:0)
这应该这样做:
var x = test.MyList.Where(c => c.MyId == 1).FirstOrDefault();