Skip to content

Add SkipLines() method for StreamReader #20

@adamfisher

Description

@adamfisher

Sometimes you may want to skip the lines in a file when reading from it with a StreamReader so having a SkipLines() method would be super helpful.

public static class StreamReaderExtensions
{
	/// <summary>
	/// Skips the specified number of lines in a stream reader based on its current position.
	/// </summary>
	/// <param name="streamReader">The stream reader.</param>
	/// <param name="skipCount">The number of lines to skip.</param>
	private static void SkipLines(this StreamReader streamReader, int skipCount)
	{
		for (var i = 0; i < skipCount && !streamReader.EndOfStream; i++)
		{
			streamReader.ReadLine();
		}
	}
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions