Converting data types?

gerrit

New member
Joined
Sep 4, 2005
Messages
1
Programming Experience
1-3
Hi all,
I have a small problem to run these lines of code. Think I missed a lection on how datatypes are converted. May someone can give me a Idea what I missed at line 05.. ;)

VB.NET:
01: Dim Config As System.IO.StreamReader = New System.IO.StreamReader("recource.cfg")
02: Dim ConfigTemp AsNew ArrayList 'Test 
03: Dim st AsString'Test
04: ConfigTemp.Add(Strings.Split(Config.ReadToEnd, vbCrLf))
05: ForEach st In ConfigTemp
06: Next



merci,
Gerrit
 
What you are doing is adding a single string array to your ArrayList. Strings.Split returns a String() (string array) and you are calling Add to add it to your ArrayList, so the ArrayList then contains one item that is a string array. if you want to add all the elements of an array to a collection, you need to call AddRange instead.
 
Back
Top