我所试图做的是,找到一个对象名单C#查找对象
Log q = logs.Find(x => (x.dnsq.queryID.Contains(queryid)));
然而,当我这样做,我得到这个错误
x.dnsq内。 queryID = 'x.dnsq.queryID' 扔 类型的异常“System.NullReferenceException
Log类看起来像这样
class Log : LogCtrl
{
public int id { set; get; }
public string source { set; get; }
public string destination { set; get; }
public string protocol { set; get; }
public double time { set; get; }
public string info { set; get; }
public DNSresponse dnsr { set; get; }
public DNSquery dnsq { set; get; }
}
你的对象之一为空或dnsq为空或queryID为null – Steve