Create a new project,
First run this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HelloWorld : MonoBehaviour {
public string[] names = new string[5];
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
Then run this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HelloWorld : MonoBehaviour {
public string[] names = new string[]{"Jesse", "Freeman"};
// Use this for initialization
void Start () {
print (names[0] + " " + names[1]);
print ("Total Names " + names.Length);
}
// Update is called once per frame
void Update () {
}
}
you will notice that the second script does not work.
This will work:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HelloWorld : MonoBehaviour {
string[] names = new string[]{"Jesse", "Freeman"};
// Use this for initialization
void Start () {
print (names[0] + " " + names[1]);
print ("Total Names " + names.Length);
}
// Update is called once per frame
void Update () {
}
}