Is there a way for creating objects at run time in c#?
for simplicity, assume the following problem..
if I have this class..
class student {
string name;
int ID;}
lets say I am writing a program that takes from the user the No. of students (e.g 15) the program then should create 15 objects from the student class and ask the user to fill the name and the ID for each student.
What I want to know is how I could create objects at run time?
First you should think about a object to save all the instances you are going to create.
Perhaps a List< Student >..
Then you can use a for-loop to create every single instance (using the new keyword) you like.
Inside the loop you can acquire user inputs to set the instance values (the student’s name and ID).