C# Container Class
Posted
by
Jamie
on Stack Overflow
See other posts from Stack Overflow
or by Jamie
Published on 2010-12-29T11:41:48Z
Indexed on
2010/12/29
11:53 UTC
Read the original article
Hit count: 204
I'm building a game in c# which allows you to script your own level, although I have come across a bit of a thought.
I have a base class called "World" as an object. This was made with a simple:
class World {
However, when the user is scripting their level, all of the game objects will be contained in the world object. I want them to be able to do something on the lines of:
World.ParentObjectName.ParentObjectProperty = "abc";
I know that the System.Windows.Forms.Panel
and other classes are like containers and can have objects in them and be accessed in that kind of way... my question is how can I make a class which is like a container in which I can add objects to, and then access them with a World.ObjectName
I have tried class World : System.Collections.CollectionBase
, but with this method, I have to keep typing World.Item("ObjectName")
Can anyone help?
Thanks!
© Stack Overflow or respective owner