Table of Contents

Struct ReadLineResult

Namespace
InteractiveReadLine
Assembly
InteractiveReadLine.dll

Represents the outcome of a read line operation: a completed line or one of two outcomes that do not produce a line.

public readonly struct ReadLineResult : IEquatable<ReadLineResult>
Implements
Inherited Members

Remarks

The simpler ReadLine methods flatten this to a string, returning null for EndOfInput and an empty string for Cancelled. Use the Read methods and this type when the difference matters, for example to tell an abandoned line apart from a genuinely empty one.

Properties

Cancelled

Gets a result representing a line the user abandoned.

public static ReadLineResult Cancelled { get; }

Property Value

ReadLineResult

EndOfInput

Gets a result representing the end of the user's input.

public static ReadLineResult EndOfInput { get; }

Property Value

ReadLineResult

IsLine

Gets whether the operation produced a line of text.

public bool IsLine { get; }

Property Value

bool

Kind

Gets how the read line operation ended.

public ReadLineResultKind Kind { get; }

Property Value

ReadLineResultKind

Text

Gets the text that the user entered. This value is non-null when Kind is Line and null otherwise.

public string? Text { get; }

Property Value

string

Methods

Equals(ReadLineResult)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(ReadLineResult other)

Parameters

other ReadLineResult

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

ForLine(string)

Creates a result carrying a finished line of text.

public static ReadLineResult ForLine(string text)

Parameters

text string

Returns

ReadLineResult

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

ToText()

Flattens this result to a string, returning the text for a finished line, null for the end of input, and an empty string for a line the user abandoned.

public string? ToText()

Returns

string