PDA

Click to See Complete Forum and Search --> : question related to array


noshaba
Sep 24th, 2006, 11:03 PM
is there any way to find out that how many nodes of an array are filled with some value

for example if i have an array like

String[] strarr = new string[10];


and i have put some values in this array using some loop ... but i dnt know each time how many values would b moved in the array

now i wanna read the array to that point where the last value is stored

can i know this thing
in c#
plz help

DNA7433
Sep 24th, 2006, 11:19 PM
Use an ArrayList instead in VS2003, or a List<string> in VS2005. It dynamically resizes so you don't have to keep track of how many nodes are used.

noshaba
Sep 24th, 2006, 11:33 PM
ok thnx but can u plz help me how could i declare List and fill it run time
sorry for bothering as m very new in C# :(

jmcilhinney
Sep 24th, 2006, 11:50 PM
Don't use the ArrayList in either case. You can use List<string> in 2005 as suggested, or you can use a Specialized.StringCollection in any version. Let Intellisense guide you.

mendhak
Sep 25th, 2006, 08:27 AM
Dim sc As New StringCollection()
sc.Add("something")

There's also the option to use sc.Insert, which lets you insert at a specific position.