C# 序列不包含用于图像处理的元素

C# 序列不包含用于图像处理的元素,c#,image,image-processing,sequence,elements,C#,Image,Image Processing,Sequence,Elements,我应该如何解决这些错误 我试图从以下方面改变: int maxClusterId = points.OrderBy(p => p.ClusterId).Last().ClusterId; 致: 但错误在于: 对象引用未设置为对象的实例。还要检查点。计数 int maxClusterId = points.OrderBy(p => p.ClusterId).LastOrDefault().ClusterId; 你说你正试图从…变为。。。但它们都是一样的。你可能应该编辑一下。。 in

我应该如何解决这些错误

我试图从以下方面改变:

int maxClusterId = points.OrderBy(p => p.ClusterId).Last().ClusterId;
致:

但错误在于:


对象引用未设置为对象的实例。

还要检查
点。计数

int maxClusterId = points.OrderBy(p => p.ClusterId).LastOrDefault().ClusterId;

你说你正试图从…变为。。。但它们都是一样的。你可能应该编辑一下。。
int maxClusterId = points.OrderBy(p => p.ClusterId).Last().ClusterId;
int maxClusterId = points.OrderBy(p => p.ClusterId).LastOrDefault().ClusterId;
if (points == null || points.Count==0) return null;