PC Review


Reply
Thread Tools Rate Thread

using ArrayList Collection class

 
 
=?Utf-8?B?ZGlhdG9tQG5ld3Nncm91cC5ub3NwYW0=?=
Guest
Posts: n/a
 
      28th Apr 2006
(Sorry if this is a re-post, don't think it worked the first time)

Hello,

I am trying to add an ArrayList as a field in my web form class.

Here is a sample:

using System;
using System.Collections;
....

ArrayList myArrayList = new ArrayList();
myArrayList.Add("Belleck Colleen Vase");
myArrayList.Add("Belinda Bradshaw Cat Bowl");
myArrayList.Add("Nicholas Mosse Cat Mug");
myArrayList.Add("Shamrock Paperweight");
myArrayList.Add("Business Card Holder");

When trying to build this web form I get the error
"Invalid tocken '(' in class, struct, or interface member declaration"

Does anyone know why I can't add an ArrayList as a field in my web form
class? I want to be able to access my ArrayList in different methods within
my web form.

Thanks
 
Reply With Quote
 
 
 
 
Alex Li
Guest
Posts: n/a
 
      28th Apr 2006
Diatom,

Seems like you have an extra ( in your code somewhere.... it is
probably just syntax error, not anything related to ArrayList at all.

HTH,
Alex

 
Reply With Quote
 
 
 
 
Barry Kelly
Guest
Posts: n/a
 
      28th Apr 2006
(E-Mail Removed)am <(E-Mail Removed)> wrote:

> myArrayList.Add("Belleck Colleen Vase");
> myArrayList.Add("Belinda Bradshaw Cat Bowl");
> myArrayList.Add("Nicholas Mosse Cat Mug");
> myArrayList.Add("Shamrock Paperweight");
> myArrayList.Add("Business Card Holder");


You can only put these statements in a method body. You must implement an
event, override a method, or create a new method and place these
statements inside the method body.

-- Barry
 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      28th Apr 2006
Hi,

Use an array instead. if you know a priori the content of it.


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"(E-Mail Removed)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> (Sorry if this is a re-post, don't think it worked the first time)
>
> Hello,
>
> I am trying to add an ArrayList as a field in my web form class.
>
> Here is a sample:
>
> using System;
> using System.Collections;
> ...
>
> ArrayList myArrayList = new ArrayList();
> myArrayList.Add("Belleck Colleen Vase");
> myArrayList.Add("Belinda Bradshaw Cat Bowl");
> myArrayList.Add("Nicholas Mosse Cat Mug");
> myArrayList.Add("Shamrock Paperweight");
> myArrayList.Add("Business Card Holder");
>
> When trying to build this web form I get the error
> "Invalid tocken '(' in class, struct, or interface member declaration"
>
> Does anyone know why I can't add an ArrayList as a field in my web form
> class? I want to be able to access my ArrayList in different methods
> within
> my web form.
>
> Thanks



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
using ArrayList Collection Class =?Utf-8?B?ZGlhdG9tQG5ld3Nncm91cC5ub3NwYW0=?= Microsoft C# .NET 1 1st May 2006 06:27 PM
serialization of user-defined class vs collection(arraylist, hasht =?Utf-8?B?UmVkIERldmls?= Microsoft Dot NET 0 11th Oct 2005 09:47 AM
a class inherited from ArrayList, is saved to ViewState, why the type of the object read from ViewSate is not the class, but the parent, ArrayList leal ting Microsoft ASP .NET 0 29th Dec 2003 08:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 AM.