Source::GetTextUpToLine Method (Int32)

 

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

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

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.

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.

Return to top
Show: