D
Daisy
I've got a class that contains a few public properties, and a public
ArrayList called Messages. The ArrayList will store other instances of this
class (thus, creating a tree).
My constructor takes 2 strings that just set properties on the class.
Adding a new Message into the ArrayList of another Message works fine:
this.Data.Messages.Add(new Message("Danny", "Something"));
But then, when I try to add a Message to that Message, eg.
this.Data.Messages[0].Messages.Add(new Message("Danny", "Something"));
I get:
error CS0117: 'object' does not contain a definition for 'Messages'
I know I'm being lazy and should probably cast it to a Message, and then try
access the Messages ArrayList of that object, but putting it in one line
like that, meant I didn't have to have a reference to an object I'm not
really using (isn't that more efficient?).
ArrayList called Messages. The ArrayList will store other instances of this
class (thus, creating a tree).
My constructor takes 2 strings that just set properties on the class.
Adding a new Message into the ArrayList of another Message works fine:
this.Data.Messages.Add(new Message("Danny", "Something"));
But then, when I try to add a Message to that Message, eg.
this.Data.Messages[0].Messages.Add(new Message("Danny", "Something"));
I get:
error CS0117: 'object' does not contain a definition for 'Messages'
I know I'm being lazy and should probably cast it to a Message, and then try
access the Messages ArrayList of that object, but putting it in one line
like that, meant I didn't have to have a reference to an object I'm not
really using (isn't that more efficient?).