C# Using Lists and RemoveAt

I’m doing something wrong but as this is my first time working with Lists, I don’t know what. My MobSpawner does this

private void SpawnAllMobs() {
	
	for(int mobcnt = 0; mobcnt < mobCount; mobcnt ++) {
				
		GameObject mob = Instantiate(mobPrefabs[Random.Range(0,mobPrefabs.Length)],
				transform.position, Quaternion.identity) as GameObject;
			
		// Get rid of (Clone), setup Parent
		mob.gameObject.name = mob.gameObject.name.Replace("(Clone)","").Trim();
		mob.transform.parent = transform;
		mob.gameObject.GetComponentInChildren<QM_EnemyHealth>().myIndex = mobcnt;
		mobs.Add(mob);
		}
	
}

and I see my bad guys have a myIndex value of 0,1,2 (where mobCount is 3) - all good there. When bad guy dies it goes into this:

public void RemoveAMob(int listIndex) {
	mobs.RemoveAt(listIndex);
	
}

the myIndex value is passed to listIndex. From that, I’m getting an error Argument is out of range Parameter name: index but not every time. If I kill mob(0) and do this RemoveAt(0), does something happen to mob(1) and (2) in the List?

http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use?

http://unitygems.com/mistakes1/

Short answer: yes, when you remove a mob from the list the indices of the rest of the mobs will get messed up because the list is now shorter! Remember, a list is not an array. When you remove an object from the list, it automatically shortens the list.

Why not make things easier for yourself, and let the list manage it for you? Immediately before you destroy the mob, use

mobs.Remove(curMob);

so that you don’t have to worry about keeping track of individual indices.