Here's a quick example. The presentation layer (ASPX page) simply has two
labels on it (lblArrayList and lblStringArray) to verify our output. The
ArrayList is part of the System.Collections namespace, so be sure to add
that in to your project.
// Create ArrayList object.
ArrayList myArrayList = new ArrayList();
// Add values; you can do this anywhere.
myArrayList.Add("Hello!");
myArrayList.Add("Goodbye!");
// Copy ArrayList to an object array.
object[] myStringArray = myArrayList.ToArray();
// Output ArrayList to our label to see the results.
foreach (string item in myArrayList)
{
lblArrayList.Text += item.ToString() + ", ";
}
// Output our array to our label to see the results.
foreach (string item in myStringArray)
{
lblStringArray.Text += item.ToString() + ", ";
}
---
David R. Longnecker
Web Developer
http://blog.tiredstudent.com
> Thanks,
> Would it be possible to give a little example of how to fill an
> ArrayList and
> convert it to a string Array after that?
> I need the string Array to call another function.
>
> On 13 apr, 14:32, "Eliyahu Goldin"
> <REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
>> No, you can't. A regular array has fixed size. You can use ArrayList
>> or other collection types for variable size.
>>
>> --
>> Eliyahu Goldin,
>> Software Developer & Consultant
>> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin
>> "Pim75" <p.meg...@tiscali.nl> wrote in message
>>
>> news: oups.com...
>>
>>> Hello,
>>>
>>> I'm defining a string array like:
>>> Dim strArray() As String = {"1", "2"}
>>> Can I add some values to this string array later in the code? It's
>>> not clear to me how to do this. I hope someone can help me.
>>>
>>> Thanks in advance!- Tekst uit oorspronkelijk bericht niet weergeven
>>> -
>>>
>> - Tekst uit oorspronkelijk bericht weergeven -
>>