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
roger rickert
NA
21
1.1k
c#/winforms object array question
Jan 11 2021 5:28 PM
hello,
I'm still pretty new to C# and teaching myself. I've searched around and haven't found an answer, so I'm wondering if anyone can let me know if this is possible.
I need to have multiple instances of a class that can be accessed by multiple forms. I know I can do this with static class or a singleton. What I need to know is if it possible to have an array of these objects so that I can reference them by index.
something like this:
(pseudocode)
public class Thing {
public int var1;
public int var2;
}
then create using
Thing[ ] thing = new Thing[4];
and reference them like:
thing[0].var1 = something;
thing[0].var2 = something;
thing[1].var1 = something;
thing[1].var2 = something;
etc.
any info to point me in the right direction is appreciated.
Reply
Answers (
2
)
how to check for duplicated items
i want to learn about c# programming