Returning all variables of a certain class within a script

This has probably been asked again and again, but Google flat-out refuses to help on this one. I’ve got this function…

	public void CleanupSprites() {
		foreach (SpriteAnim anim in this) { // almost certainly wrong, and that's why I'm asking
			for (int j = 0; j < anim.instances.Count; j++) {
				RemoveSprite (anim, j);

…which calls this one…

	public SpriteAnim RemoveSprite (SpriteAnim sprite, int instance) {
		if (sprite.instances [instance] != null) {
			Destroy (sprite.instances [instance]);
			sprite.instances.RemoveAt (instance);
		return sprite;

…both of which are fed a custom Serializable class called SpriteAnim. The console informs me that a foreach loop can’t be done like this, so I’m asking what the way to go would be.

instead of foreach do

for (int i = 0; i < this.Length; i++)