Unable to Remove Multiple Shapes with the Same Width and Height from Presentation Slides

Hi,
After posting this issue:Unable to Remove All Shapes from Presentation Slides,I am confronted with a new problem in removing multiple shapes.
I’m trying to write a piece of code that can remove multiple shapes with the same width and height form all slides.
My code is as follows:

Presentation pres = new Presentation(filename);
for (int islide = 0; islide < pres.Slides.Count; islide++)
{
    ISlide slide = pres.Slides[islide];
    for (int ishp = 0; ishp < slide.Shapes.Count; ishp++)
    {
        IShape shp = slide.Shapes[ishp];
        if (shp.Height = Convert.ToSingle(Height) & shp.Width = Convert.ToSingle(Width))
        {
            slide.Shapes.Remove(shp);
        }
    }
}

I found that when there are multiple shapes with the same height and width, only some(maybe 2 or 3) of them can be deleted and the rest still exist.
Could you please tell me how I can fix this ?
Thanks and Regards :heartbeat:

@Loui,
Thank you for contacting support.

You are encountering the same problem described in the topic you mentioned above. You cannot enumerate the shape collection and remove items in the same time. I described the way for you there.

1 Like

Thank you so much for replying me! :heartbeat: :heartbeat:
You’ve really helped me a lot :heartbeat: :heartbeat:

@Loui,
Thank you for using Aspose.Slides.