-3

我有一个 TileToDraw 类型的列表,该类型声明如下:

[StructLayout(LayoutKind.Sequential)]
struct TileToDraw
{
    public Vector2 origin;
    public string type;

    public TileToDraw(Vector2 originIn, string typeIn)
    {
        origin = originIn;
        type = typeIn;
    }
}

我已经填充了这个,但想删除具有特定原点(矢量)的图块。我应该为此使用哪个功能?

4

1 回答 1

4

You can use LINQ to create new List<TileToDraw> with elements from sourceList that satisfy condition:

var newList = sourceList.Where(x => x.Origin != myOrigin).ToList();

or use List<T>.RemoveAll method to remove elements from sourceList directly:

sourceList.RemoveAll(x => x.Origin == myOrigin);
于 2013-04-20T20:44:03.953 回答