find size of a prefab that is spawned from an array

Hello, I recently started with Unity and C# so I am fairly new and encountered this obstacle I can’t find solution for.
I am randomly spawning differently sized(i have 6 prefabs) platforms from an array. I want the next platform to be spawned after the previous one with a some kind of gap(that the player is available to jump over) and for this i need to know width of the spawned platform(prefab). The “spawner” itself is working I mean it spawns platforms, but I have problems with position. I searched all over but I don’t seem to find anything related to this situation. I tried using bounds.size but i get the following error:

error CS0120: An object reference is
required to access non-static member
`UnityEngine.Collider2D.bounds’

I attach my current code of the spawner and would really appreciate any help or hints. Thank you in advance.

using UnityEngine;
using System.Collections;

public class PlatformSpawnScript : MonoBehaviour {

	public GameObject[] platforms;
	public int maxPlatforms = 10;
	public float horizontalMin = 1f;
	public float horizontalMax = 5f;

	private Vector2 startingPosition;



	// Use this for initialization
	void Start () {

		startingPosition = transform.position;
		spawn ();

	
	}

	void spawn (){
		for (int i = 0; i < maxPlatforms; i++) {

			Instantiate(platforms[Random.Range (0, 5)], startingPosition, Quaternion.identity);
			startingPosition += (Collider2D.bounds.size.x + Random.Range[1f, 5f]);

		}
	}



}

alt text

Collider2D is a component. On line 28 use

GetComponent<Collider2D>().bounds.size.x