I am trying to create an array of objects from Person objects in Employee class but I am getting these errors:
CS0270 Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)
CS1519 Invalid token '.' in class, struct, or interface member declaration CS1519
Invalid token '=' in class, struct, or interface member declaration
void Main()
{
}
public class Person{
public string Name{ get; set;}
}
public class Employee{
Person[] persons = new Person[3];
persons[0].Name = "Ali";
}
What am I doing wrong?
persons[0].Name = "Ali";needs to be inside a method