adding components to a gameObject in a list of lists

im trying to add components to a gameobject thats inside a list of lists,

im getting the error

Assets/createplane.cs(151,71): error CS1061: Type System.Collections.Generic.List' does not contain a definition for AddComponent’ and no extension method AddComponent' of type System.Collections.Generic.List’ could be found (are you missing a using directive or an assembly reference?)

the error is on the line

MeshFilter meshFilter = (MeshFilter)thePlanes[(int)z].AddComponent(typeof(MeshFilter));

i think im not accessing the .addcomponent of the gameobject in the list properly, but im not sure,

List<List<GameObject>> thePlanes;

void Awake()
	{
		List<List<GameObject>> thePlanes = new List<List<GameObject>>();
		
		for(float i = 0;i<planecount;i++)
		{
			thePlanes.Add(new List<GameObject>());
			
			for(float j = 0;j<planecount;j++)	
			{
				MakePlane(i,j);
			}
		}
	}

void MakePlane(float x, float z)
	{
		//GameObject plane = new GameObject("Plane x="+x+" z="+z);
		thePlanes[(int)z].Add(new GameObject("Plane x="+x+" z="+z));
		//MeshFilter meshFilter = (MeshFilter)plane.AddComponent(typeof(MeshFilter));
		MeshFilter meshFilter = (MeshFilter)thePlanes[(int)z].AddComponent(typeof(MeshFilter));
		meshFilter.mesh = CreatePlane(size);
		//MeshRenderer renderer = plane.AddComponent(typeof(MeshRenderer)) as MeshRenderer;
		MeshRenderer renderer = (MeshRenderer)thePlanes[(int)z].AddComponent(typeof(MeshRenderer));
   	 	renderer.material.shader = Shader.Find ("Particles/Additive");
    	Texture2D tex = new Texture2D(1, 1);
    	tex.SetPixel(0, 0, Color.green);
    	tex.Apply();
		renderer.material.mainTexture = tex;
   		renderer.material.color = Color.green;
		meshFilter.transform.Translate(new Vector3((x*size*(size-1)),0,(z*size*(size-1))));
		//thePlanes[(int)z].Add(plane);
	}

i think ive got it correct, im doing it the same way i was doing it before i put them in the list, but its not working for this

I solved my problem, I wasn’t referencing the correct item in the list, in several places.

 void Awake()
    	{
    		thePlanes = new List<List<GameObject>>();
    		
    		for(float i = 0;i<planecount;i++)
    		{
    			thePlanes.Add(new List<GameObject>());
    			for(float j = 0;j<planecount;j++)	
    			{
    				MakePlane(i,j);
    			}
    		}
    	}
    	
    	void MakePlane(float x, float z)
    	{
    		//GameObject plane = new GameObject("Plane x="+x+" z="+z);
    		thePlanes[(int)x].Add(new GameObject("Plane x="+x+" z="+z));
    
    		//MeshFilter meshFilter = (MeshFilter)plane.AddComponent(typeof(MeshFilter));
    		MeshFilter meshFilter = (MeshFilter)thePlanes[(int)x][(int)z].AddComponent(typeof(MeshFilter));
    		meshFilter.mesh = CreatePlane(size);
    		//MeshRenderer renderer = plane.AddComponent(typeof(MeshRenderer)) as MeshRenderer;
    		MeshRenderer renderer = (MeshRenderer)thePlanes[(int)x][(int)z].AddComponent(typeof(MeshRenderer));
       	 	renderer.material.shader = Shader.Find ("Particles/Additive");
        	Texture2D tex = new Texture2D(1, 1);
        	tex.SetPixel(0, 0, Color.green);
        	tex.Apply();
    		renderer.material.mainTexture = tex;
       		renderer.material.color = Color.green;
    		meshFilter.transform.Translate(new Vector3((x*size*(size-1)),0,(z*size*(size-1))));
    		//thePlanes[(int)z].Add(plane);
    	}

Try doing MeshFilter meshFilter = ((MeshFilter)thePlanes[(int)z]).AddComponent(typeof(MeshFilter));