Array.Length-1 should point to last member of array?

SleepingTroll

Newcomer
Joined
Feb 14, 2012
Maybe it is just a brain fart, however the highlighted line of my code produces and index out of range error... can anyone spot the problem?


Code:
		public void AddParticle()
		{
			Array.Resize(ref Particlestemp, Particlestemp.Length);
			Array.Copy(Particles, Particlestemp, Particles.Length);
			Array.Resize(ref Particles, Particles.Length);
			Array.Copy(Particlestemp, Particles, Particles.Length);
			Array.Resize(ref ParticleMeshtemp, ParticleMesh.Length);
			Array.Copy(ParticleMesh, ParticleMeshtemp,ParticleMesh.Length);
			Array.Resize(ref ParticleMesh, ParticleMesh.Length);
			[COLOR="Red"]ParticleMesh[ParticleMesh.Length-1] = Mesh.Sphere(device, 4, 64, 64 );[/COLOR]
			ParticleMaterial[Particles.Length-1].Ambient = Color.Green;
			ParticleMaterial[Particles.Length-1].Diffuse = Color.Green;
			ParticleMaterial[Particles.Length-1].Specular = Color.Green;
			ParticleMaterial[Particles.Length-1].SpecularSharpness = 100;
			VelocityX.Add(1);
			VelocityY.Add(1);
			VelocityZ.Add(1);
			PositionX.Add(1);
			PositionY.Add(1);
			PositionZ.Add(1);
		}
 
Top Bottom