0
请帮帮我!我写了下面的程序,有一个错误“变量”arr“之前使用...”我试图修复,但我不能。请帮助我:)非常感谢!Visual Basic错误“变量之前使用......”
Imports System
Imports System.IO
Class Test
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("a.txt")
Dim line As String
Dim arr()() As Char
Dim tem As Integer
tem = 1
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
arr(tem) = line.ToCharArray
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
End Sub
End Class
Module Module1
Sub Main()
Test.Main()
End Sub
End Module
之前干什么用的?你明白错误的含义吗? – SLaks 2012-04-19 20:34:56
请注意,你刚刚(很差)重新发明'File.ReadAllLines()'。 – SLaks 2012-04-19 20:37:21
警告\t \t 1变量“改编”它已经被分配了值之前被使用。运行时可能会导致空引用异常。而且我明白,但我无法找到修复它的方法 – smile232 2012-04-19 20:37:50