- Home /
 
 
               Question by 
               user-10013 (google) · Apr 15, 2011 at 05:51 PM · 
                arrayclassvalueenter  
              
 
              Enter value in Class array how?
My code:
var Cars : CarsInfo[]; class CarsInfo { var Name : String = ""; var ID : int = 0; }
 
               function Start () {
 
                Cars = new CarsInfo[1]; Cars[0].Name = "Test"; //Dont work! Cars[0].ID = 12; //Dont work!
  
               } 
How enter the value? Thanks! Sorry my English!
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Mike 3 · Apr 15, 2011 at 06:05 PM
You need to initialize the items in the array
Cars = new CarsInfo[1];
Cars[0] = new CarsInfo(); //this is the line you need
Cars[0].Name = "Test"; 
Cars[0].ID = 12;
 
              Your answer