473,394 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

using ArrayList Collection Class

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
Apr 28 '06 #1
1 1341
Hi,

You cannot initialize it that way , if it's an instance variable.

A possible solution would be

ArrayList myArrayList = new ArrayList( new String[] { "str 1" , "str 2" } )
Cheers,

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

"di****@newsgroup.nospam" <di****@newsgroup.nospam.donotspam> wrote in
message news:87**********************************@microsof t.com...
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

May 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tamir Khason | last post by:
How can I set the type of the object added to ArrayList (type of Array List Members) Here is the code: protected ArrayList tabs = new ArrayList(); public ArrayList Tabs {
2
by: j3ko | last post by:
Hi, I'm trying to start a thread that constantly iterates through an arraylist of items that the main thread adds and removes from...how would I accomplish this? Here's the gist of what I have:...
3
by: starter | last post by:
I am trying to learn IEnumerator and collections(ArrayList, Hashtable) in .NET. Can anyone tell me what is IEnumerator used for and any online resources would be helpful. Thanks
0
by: Yofnik | last post by:
Is there a way to avoid serializing an empty ArrayList? I would like the following class: public class Collection { public ArrayList Items = new ArrayList(); } ....to serialize like this:
3
by: diatom | last post by:
(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...
5
by: res7cxbi | last post by:
I like to implement and ArrayList like Java's and C# in C++ but I have no clue how to start I really don't want to use Managed C++ and use ArrayList that way - I want to keep it "unmanaged" Can...
3
by: Michael Slattery | last post by:
Hello, I see quite a few questions, but no valid responses to the question... How do I store an ArrayList of items in a Properties file via the GUI? I am able to select the...
11
mia023
by: mia023 | last post by:
Hello everyone. Assume that we have previously defined the following class StockPurchase that has the following as instance variables a) The name of the stock (a string) b) The number of...
6
by: David C | last post by:
In my business layer, I have Person, and Patient which derives from Person. //base class for all single classes public class BaseItem{} public class Person:BaseItem{} public class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.