Eitan wrote:
Hello Colin,
Thank you for your answer.
I tried the line below (before posting my question):
public static List<myListElement>[] myList = new
List<myListElement>[4]();
The difference is the brackets "()" after "[4]". The compiler generated
an error.
Can you explain to me why the error, and when would you need the brackets
"()"?
Thank you,
Eitan
"colin" wrote:
>>
"Eitan" <Ei***@discussions.microsoft.comwrote in message
news:55**********************************@microso ft.com...
Hello,
I am declaring an element like this:
public static List<myListElementmyList = new List<myListElement>();
I would like to declare an array of this myList.
How would I modify the declaration of myList so it will represents an
array?
Thanks
Eitan
public static List<myListElement>[] myList = new List<myListElement>[4];
Colin =^.^=
Hi Eitan,
If you take a look at my response it may be a bit clearer what is going on.
When you're defining the array, you aren't constructing the List<objects,
just constructing an array of list objects. Parentheses are not required
for constructing an array, as the construction doesn't take parameters,
only a size of array to create given in the square brackets.
So, that being the case, you'll have to manually construct each List<>
object in your array.
--
Tom Spink
University of Edinburgh