c# - Why does the Console keep writing the same output for the elements in my array? -


i'm new c# programming. trying create new objects (in case studentinfo object) , place them in array studentarr.

the array initialized length = 5 , want create 5 studentinfo objects , add them array. don't think it's doing @ , don't know i'm going wrong.

i'm supposed enter student information through console.readline 5 different students , it's printing out first student information.

i'm using struct access student info.

some appreciated!

static void main(string[] args) {     studentinfo[] studentarr = new studentinfo[5];      int objectnumber = 0;     (int = 0; < studentarr.length; i++)     {         studentarr[i] = new studentinfo();          console.writeline("please enter studentid, studentname, coursename, date-of-birth");          studentarr[i].firstname = console.readline();         studentarr[i].lastname = console.readline();         studentarr[i].birthday = console.readline();         studentarr[i].studentid = console.readline();         studentarr[i].addressline1 = console.readline();         studentarr[i].addressline2 = console.readline();         studentarr[i].city = console.readline();         studentarr[i].state = console.readline();         studentarr[i].zipcode = console.readline();         studentarr[i].country = console.readline();          objectnumber = + 1;     }      (int = 0; < studentarr.length; i++)     {         console.writeline(             "{0} {1} born on {2}. student id: {3}",              studentarr[0].firstname, studentarr[0].lastname,              studentarr[0].birthday, studentarr[0].studentid);          console.writeline(             "address: {0} {1} \n\t {2} {3} {4} {5}.",              studentarr[0].addressline1, studentarr[0].addressline2,              studentarr[0].city, studentarr[0].state, studentarr[0].zipcode,              studentarr[0].country);     } }  public struct studentinfo {     public string firstname;     public string lastname;     public string birthday;     public string studentid;     public string addressline1;     public string addressline2;     public string city;     public string state;     public string zipcode;     public string country;      // constructor studentinfo     public studentinfo(         string first, string last, string dob, string id,          string address1, string address2, string city,          string state, string zip, string country)     {         this.firstname = first;         this.lastname = last;         this.birthday = dob;         this.studentid = id;         this.addressline1 = address1;         this.addressline2 = address2;         this.city = city;         this.state = state;         this.zipcode = zip;         this.country = country;     } } 

you printing first element @ 0 writing studentarr[0]. should studentarr[i]

for (int = 0; < studentarr.length; i++) {      console.writeline("{0} {1} born on {2}. student id: {3}", studentarr[i].firstname, studentarr[i].lastname, studentarr[i].birthday, studentarr[i].studentid);     console.writeline("address: {0} {1} \n\t {2} {3} {4} {5}.", studentarr[i].addressline1, studentarr[i].addressline2, studentarr[i].city, studentarr[i].state, studentarr[i].zipcode, studentarr[i].country); }