By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,673 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,673 IT Pros & Developers. It's quick & easy.

'object' does not contain a definition for 'MyArrayList'

P: n/a
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?).

--
Daisy The Cow
Now playing: Nothing
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Daisy" <da***@nospam.oops> wrote in message
news:be**********@linux01.dannytuppeny.com...
<snip>

Oops, seems I can do it with brackets:

((Message) this.Data.Messages[0]).Messages.Add(new Message("Danny",
"Something"));

:o)
--
Daisy The Cow
Now playing: Nothing
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.