2017-02-20 85 views
0

我有迷你班,我保存在列表中。现在我必须删除列表中的行,其中numRect = -1。我该怎么做?从列表中删除一定的值

double pointX, pointY; 
int numRect; 
public PointsSelectedSources(double x, double y, int numRect) 
{ 
    pointX = x; 
    pointY = y; 
    this.numRect = numRect; 
} 
public int NumRect 
{ 
    get 
    { 
     return numRect; 
    } 
    set 
    { 
     numRect = value; 
    } 
} 
+0

我会避免命名类值和constructor属性都numRect,即使代码明白你的意思,它的坏的形式,并就更难别人看你的码。 – Andrew

回答

1

miniClassList被列入名单,那么你可以这样做以下从这些具有列表中删除所有对象numRect = -1;

miniClassList.RemoveAll(x=> x.numRect == -1); 

Working example更多的澄清