[SOLVED] C# List. Doesn't work with "EditorWindow"

I declare a List with MonoBehaviour and all is well:

public class NewBehaviourScript : MonoBehaviour {

	void Start () {	
 	List<string> colorList = new List<string>();
	colorList.Add ("Red");
	}
}

BUT if I try the same with EditorWindow I get a parsing error.

public class cPopupWindow : EditorWindow{

	void Start () {	
 	List<string> colorList = new List<string>();
	colorList.Add ("Red"); //<------Parsing Error!!
	}
}

Are Lists not supported in the Editor?

*EDIT solved, can’t call the Add() functions directly after the declaration. Moved the Add() to the Awake() function and it works.

Are you sure you’re including

using System.Collections.Generic;

in your editor window script?

Yes, these are what I’m including:

using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.IO;
using System.Collections.Generic;

Ok, my problem is that I was trying to Add() directly after the declaration. I moved the Add() function inside of an awake and it compiles.

You should be able to. Perhaps the line endings in your file are inconsistent? That occasionally causes weird syntax errors.

Your fix was not the problem, you should be able to Add() to a List immediately - something else was going wrong here. I do this kind of thing all the time…