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
"(E-Mail Removed)" <(E-Mail Removed)> wrote in
message news:87078CCF-62CF-4DE9-AC0A-(E-Mail Removed)...
> 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
|