0

私を助けてください!以下のプログラムを書きましたが、「変数 "arr" が前に使われています...」という間違いがあり、修正しようとしましたが、できませんでした。私を助けてください:)どうもありがとう!

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
4

1 に答える 1

1

arr変数を初期化する必要があります。

必要な配列の大きさがわからないため、List(Of T)代わりに a を使用する必要があります。

于 2012-04-19T20:37:00.540 に答える