Why does the following code print 'foo' Length: 10000
?
How do I discard the unused array elements such that the string is "Length: 3"?
Dim arr(9999) as char
Dim sw As StreamWriter = New StreamWriter("example.txt")
sw.WriteLine("foo")
sw.Close()
Dim sr As StreamReader = New StreamReader("example.txt")
sr.ReadBlock(arr, 0, 10000)
sr.Close()
Dim con as string = New String(arr)
Console.WriteLine(String.Format("'{0}' Length: {1}", con, con.Length.ToString()))