다음을 통해 공유


Source.GetTextUpToLine Method

Gets the text from the source up to and including the given line number.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)

Syntax

‘선언
Public Function GetTextUpToLine ( _
    line As Integer _
) As String
public string GetTextUpToLine(
    int line
)

Parameters

  • line
    Type: System.Int32
    The line number of the last line of text to obtain. Specify 0 to obtain all the text in the source.

Return Value

Type: System.String
All the text up to and including the given line.

Remarks

This method calls the GetLastLineIndex method on the IVsTextLines object passed to the Source class constructor to get the total number of lines. If line is 0, use the total number of lines (minus 1) as the last line; otherwise, use line if it does not exceed the total number of lines. Finally, get the length of the last line to obtain (with a call to GetLengthOfLine), and return the result from a call to GetText(Int32, Int32, Int32, Int32). This method throws an exception if either GetLastLineIndex or GetLengthOfLine return errors.

.NET Framework Security

See Also

Reference

Source Class

Microsoft.VisualStudio.Package Namespace