Need help with aray

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SpawnerEnemy : MonoBehaviour {

public Text Wavetext;

public GameObject []enemies;

int[] wave;

int Cwave = 0;

Vector3 positionofspawn;

float x;
float z;

// Use this for initialization
void Start () {
	wave [0] = 15;
	 positionofspawn= new Vector3(transform.position.x,transform.position.y,transform.position.z);
	x = transform.position.x;
	z = transform.position.z;
}

// Update is called once per frame
void Update () {
	

	if (GameObject.FindGameObjectsWithTag ("enemy").Length <1 ) {
		for (int i = 0 ; i < wave [Cwave]; i++ ) {
			int enemyToSpawn = Random.Range (0, enemies.Length);
			positionofspawn.x = Random.Range(80 , -80);
			positionofspawn.z = Random.Range(80 , -80);
			Instantiate (enemies [enemyToSpawn], positionofspawn, Quaternion.identity);
		}
		wave [Cwave + 1] = wave [Cwave += 15];
		Cwave++;
		Wavetext.text = Cwave.ToString () + "     " +  wave [Cwave].ToString ();

	}
}	

}

this is my script , what I want is that every next wave num of enemeis is 15+ . I get NullReferenceException: Object reference not set to an instance of an object
SpawnerEnemy.Update () (at Assets/codes/SpawnerEnemy.cs:32)
but when I add numbers in wave it works int wave = {15,30,45…} I want it to make like this so it dosent come to the end .

If you just set

int[] wave;

the variable named wave is still null. You have to do something like

int[] wave = new int[42];

(For 42 insert the number of elements you want the array to have).

Or you can do that later, e.g. in your Start()-method

 wave = new int[42];

When you give initial values (as you do with {15, 30, 45 }), this is implicitly done for you. So

int[] wave = { 15, 30, 45 };

is kind of just short for

int[] wave = new int[3];
wave[0] = 15;
wave[1] = 30;
wave[2] = 45;

That’s why your code does not crash in that case.

See https://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx for array-basics in c#.

Use generic lists C# List Examples - Dot Net Perls This way you can do anything dinamically.

List waves = new List();

// add wave
waves.add(15);

//Iterate
foreach (int wave in waves)
{
// your code …
}