TextFieldParser.LineNumber Свойство

Определение

Возвращает номер текущей строки или значение "–1", если в потоке не осталось символов.

public:
 property long LineNumber { long get(); };
public long LineNumber { get; }
member this.LineNumber : int64
Public ReadOnly Property LineNumber As Long

Значение свойства

Текущий номер строки.

Примеры

В этом примере выполняется поиск имени Jones в текстовом файле и сообщается, в каких строках оно встречается.

Using FileReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\ParserText.txt")
    FileReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
    FileReader.Delimiters = New String() {","}
    Dim currentRow As String()
    While Not FileReader.EndOfData
        Try
            currentRow = FileReader.ReadFields()
            Dim currentField As String
            For Each currentField In currentRow
                If currentField = "Jones" Then
                    MsgBox("The name Jones occurs on line " & 
                    FileReader.LineNumber)
                End If
            Next
        Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
            MsgBox("Line " & ex.Message & 
           "is not valid and will be skipped.")
        End Try
    End While
End Using

Комментарии

Это расширенный член; Он не отображается в IntelliSense, если не щелкнуть вкладку Все .

Пустые строки и примечания не игнорируются при определении номера строки.

Применяется к

См. также раздел