rog_rickert
Member
- Joined
- Dec 17, 2020
- Messages
- 11
- Programming Experience
- Beginner
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 an object 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.
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 an object 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.