对象未设置为引用对象错误

时间:2015-12-21 19:43:48

标签: c# error-handling nullreferenceexception

所以,是的......它的错误。鉴于代码,我不知道我缺少什么或没有做到让它工作:

RegionQuery(allPointsDbscan, p.ClusterPoint, epsilon, deltaX, deltaY, out neighborPts);

if (neighborPts != null)
{
  if (neighborPts.Length < minPts)
      p.ClusterId = (int)ClusterIds.Noise;
  else
  {
      clusterId++;
      ExpandCluster(allPointsDbscan, p, neighborPts, clusterId, epsilon, minPts, deltaX, deltaX);
  }
}



private void RegionQuery(DbscanPoint[] allPoints, DatasetItem point, double epsilon, double delta_X, double delta_Y, out DbscanPoint[] neighborPts)
{
   if (delta_X < 0.1499 && delta_Y < 0.0899)
   {
       neighborPts = allPoints.Where(x => _metricFunc(point, x.ClusterPoint) <= epsilon).ToArray(); 
   }
   else
       neighborPts = null;
}

我不明白为什么它会抛弃我的异常,因为在我对它做任何事情之前,我会检查neighborPts是否NULL;但似乎我甚至不能这样做。这是为什么?

0 个答案:

没有答案