As we know that a simple array can be initialized like this for example, int [] TestArray = {1,2,3,4}
, but how about if we use an array with a structure object and we want to initialize it?
I know that we can access the structure object array like this for example,
Suppose struct Automobile
is our structure and we have field in it such as public int year
, public string model
and we create an array structure object for example, Automobile [] Car = new Automobile();
so we can access the element of a structure array object and give it a value if we use it with structure field for example, Car[2].year = "2016"
and then can display it in for example,
MessageBox.Show(Car[2].year.ToString());
But what if we want our structure array object to having initial values like we have it in normal array initialization as written in the start?