I apologies if this is a duplicate question;
I can find out the number of elements in array:
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour
{
string[] myThings = new string[] {"Banana", "Dinosaur", "Gwen Stefani"};
// int l = myThings.Length; // FAIL!
// Use this for initialization
void Start ()
{
ProcessThings();
}
void ProcessThings ()
{
//int l = myThings.Length;
print("Things: " + l);
}
}
My question is this why can't I declare l= myThings.Length outside of method (line 9)? A field initializer cannot reference the nonstatic field, method, or property `Test.myThings'
Go easy on me, I'm learning :)
Moving up from crayons to C#