Method Parse
Parse(string?, IFormatProvider?)
[Pure]
public 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.
[Pure]
public 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?)
Parses a span of UTF-8 characters into a value.
[Pure]
public static Color Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Parameters
utf8TextReadOnlySpan<byte>The span of UTF-8 characters to parse.
providerIFormatProviderAn object that provides culture-specific formatting information about
utf8Text.
Returns
- Color
The result of parsing
utf8Text.
Exceptions
- FormatException
utf8Textis not in the correct format.- OverflowException
utf8Textis not representable by Color.