java - Create Object Name with Array -
i want create object name using arrays. how can it?
for example :
string dizi ={"person1","person2","person3"}; person dizi[0] = new person();
you cannot change type of object stored in array string person. instead, need 2 separate arrays, , supposing have person(string) constructor, loop on first array fill second array:
string[] names = {"person1","person2","person3"}; person[] persons = new person[3]; (int = 0; < 3; i++) persons[i] = new person(names[i]);
Comments
Post a Comment