Show / Hide Table of Contents

ReadLine Examples

string ReadLine()

Text.txt

Hello world

TextComparer.cs

public class TextComparer
{
    using TextInteractor;

    public static Main(string[] args)
    {
        TextFile file = new TextInteractor("Text.txt")

        file.Open();

        Console.Writeline(file.ReadLine());
        //Hello World

        file.Close();
    }
}

void RestartReading()

Text.txt

Hello world
There is one more line.
Goodbye.

TextComparer.cs

public class TextComparer
{
    using TextInteractor;

    public static Main(string[] args)
    {
        TextFile file = new TextInteractor("Text.txt")

        file.Open();

        Console.Writeline(file.ReadLine());
        //Hello World

        Console.Writeline(file.ReadLine());
        //There is one more Line.

        file.RestartReading();
        Console.Writeline(file.ReadLine());
        //Hello World

        file.Close();
    }
}

bool FinishedReading()

Text.txt

Hello world.
Good Bye.

TextComparer.cs

public class TextComparer
{
    using TextInteractor;

    public static Main(string[] args)
    {
        TextFile file = new TextInteractor("Text.txt")
        
        file.Open();

        Console.Writeline(file.ReadLine());
        //Hello World

        Console.Writeline(file.FinishedReading());
        //False

        Console.Writeline(file.ReadLine());
        //Good Bye.
        
        Console.Writeline(file.FinishedReading());
        //True

        file.Close();
    }
}
  • Improve this Doc
Back to top Generated by DocFX