嗨,我在我的项目中有以下代码
class CVote
{
public int id;
public int studentId;
public string answer;
public int questionIndex;
//public DateTime occurred;
}
public static List<CVote> votes = new List<CVote>();
我想获取某些studentID的索引(例如:studentID 15),所以我尝试以下代码
int test = -1;
test = Global.votes.IndexOf(15);
但这以错误结果结尾
任何想法如何正确地做到这一点?
你需要 FindIndex
var std = votes.FindIndex(x=>x.id == 15)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句