Table of Contents

Method TryParse

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

TryParse(string?, IFormatProvider?, out Color)

Converts the provided string to a new Color value.

[Pure]
public static bool TryParse(string? text, IFormatProvider? formatProvider, out Color result)

Parameters

text string

The text to analyze. Formats supported are "#RGB", "#RRGGBB", "#ARGB", "#AARRGGBB", "rgb(r,g,b)", "rgb(r,g,b,a)", "rgba(r,g,b)", "rgba(r,g,b,a)", and any of the GetClosestNamedColor16(Color) string values.

formatProvider IFormatProvider

Optional IFormatProvider to provide formatting services for the input text.
Defaults to InvariantCulture if null.

result Color

The parsed value, if successful, or default(Color), if unsuccessful.

Returns

bool

A bool value indicating whether parsing was successful.

Remarks

While Color supports the alpha channel A, Terminal.Gui does not.

TryParse(ReadOnlySpan<char>, IFormatProvider?, out Color)

Converts the provided ReadOnlySpan<T> of char to a new Color value.

[Pure]
public static bool TryParse(ReadOnlySpan<char> text, IFormatProvider? formatProvider, out Color color)

Parameters

text ReadOnlySpan<char>

The text to analyze. Formats supported are "#RGB", "#RRGGBB", "#ARGB", "#AARRGGBB", "rgb(r,g,b)", "rgb(r,g,b,a)", "rgba(r,g,b)", "rgba(r,g,b,a)", and any W3C color name."/> string values.

formatProvider IFormatProvider

If specified and not null, will be passed to Parse(ReadOnlySpan<char>, IFormatProvider?).

color Color

The parsed value, if successful, or default(Color), if unsuccessful.

Returns

bool

A bool value indicating whether parsing was successful.

Remarks

While Color supports the alpha channel A, Terminal.Gui does not.

TryParse(ReadOnlySpan<byte>, IFormatProvider?, out Color)

Tries to parse a span of UTF-8 characters into a value.

[Pure]
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Color result)

Parameters

utf8Text ReadOnlySpan<byte>

The span of UTF-8 characters to parse.

provider IFormatProvider

An object that provides culture-specific formatting information about utf8Text.

result Color

On return, contains the result of successfully parsing utf8Text or an undefined value on failure.

Returns

bool

true if utf8Text was successfully parsed; otherwise, false.

TryParse(string, out Color?)

Converts the provided string to a new Color instance.

public static bool TryParse(string text, out Color? color)

Parameters

text string

The text to analyze. Formats supported are "#RGB", "#RRGGBB", "#ARGB", "#AARRGGBB", "rgb(r,g,b)", "rgb(r,g,b,a)", "rgba(r,g,b)", "rgba(r,g,b,a)", and any of the ColorName16 string values.

color Color?

The parsed value.

Returns

bool

A boolean value indicating whether parsing was successful.

Remarks

While Color supports the alpha channel A, Terminal.Gui does not.