Table of Contents

Method ToString

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

ToString(string?, IFormatProvider?)

Returns a string that represents the current object.

public string ToString(string? formatString, IFormatProvider? formatProvider = null)

Parameters

formatString string

A format string that will be passed to Format(IFormatProvider, string, params object[]).

See remarks for parameters passed to that method.
formatProvider IFormatProvider

An optional IFormatProvider to use when formatting the Color using custom format strings not specified for this method. Provides this instance as Argb.
If this parameter is not null, the specified IFormatProvider will be used instead of the custom formatting provided by the Color type.

See remarks for defined format strings.

Returns

string

A string that represents the current object.

Remarks

Pre-defined format strings for this method, if a custom formatProvider is not supplied are:

Value-Result

  • g or null or empty string General/default format - Returns a named Color if there is a match, or a 24-bit/3-byte/6-hex digit string in "#RRGGBB" format.
  • G Extended general format - Returns a named Color if there is a match, or a 32-bit/4-byte/8-hex digit string in "#AARRGGBB" format.
  • d Decimal format - Returns a 3-component decimal representation of the Color in "rgb(R,G,B)" format.
  • D Extended decimal format - Returns a 4-component decimal representation of the Color in "rgba(R,G,B,A)" format.

If formatProvider is provided and is a non-null ICustomColorFormatter, the following behaviors are available, for the specified values of formatString:

Value-Result

ToString()

Converts the color to a string representation.

[Pure]
public override string ToString()

Returns

string

The string representation of this value in #RRGGBB format.

Remarks

If the color is a named color, the name is returned. Otherwise, the color is returned as a hex string.

A (Alpha channel) is ignored and the returned string will not include it for this overload.