Method Parse
Parse(string?, IFormatProvider?)
static Color Parse(string? text, IFormatProvider? formatProvider = null)
Parameters
textstringThe 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.
formatProviderIFormatProviderIf specified and not null, will be passed to Parse(ReadOnlySpan<char>, IFormatProvider?).
Returns
Remarks
Exceptions
- ArgumentNullException
If
textis null.- ArgumentException
If
textis an empty string or consists of only whitespace characters.- ColorParseException
If thrown by Parse(ReadOnlySpan<char>, IFormatProvider?).
Parse(ReadOnlySpan<char>, IFormatProvider?)
Converts the provided ReadOnlySpan<T> of char to a new Color value.
static Color Parse(ReadOnlySpan<char> text, IFormatProvider? formatProvider = null)
Parameters
textReadOnlySpan<char>The text to analyze. Formats supported are "#RGB", "#RRGGBB", "#RGBA", "#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.
formatProviderIFormatProviderOptional IFormatProvider to provide parsing services for the input text.
Defaults to InvariantCulture if null.
If not null, must implement ICustomColorFormatter or will be ignored and InvariantCulture will be used.
Returns
Remarks
Exceptions
- ArgumentException
with an inner FormatException if
textwas unable to be successfully parsed as a Color, for any reason.
Parse(ReadOnlySpan<byte>, IFormatProvider?)
static Color Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Parameters
utf8TextReadOnlySpan<byte>providerIFormatProvider