TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
James Webb
NA
11
9.6k
Creating Objects
Jun 28 2014 1:00 PM
Hi all,
I'm still very new with C# and I have just started to get my head round objects.
What I would like to know is how would I program a way of making any number of objects and give each object a name like "Person_1" and "Person_2".
Is this even possible? I have tried the following but it doesn't work:
for (int i = 0; i < count; i++)
{
Player ("Player_" + i) = new Player();
}
Is there a better way to go about doing this? The big picture (if its any use) is my program reading from a text file using streamreader and creating an object every 6 lines (my object has 6 parameters). There will be a maximum of around 100 objects so I really would like a much more efficient way of creating these objects.
Many Thanks and Kind Regards,
James Webb
P.S. Please remember I'm a beginner, try to keep it as simple as possible and explain as much as you can, it would be very much appreciated!
Reply
Answers (
1
)
I am looking for online editor functionality in mvc app
Sharing Variable Values Between Forms in Visual Studio C#