Method Parse
Parse(string?, IFormatProvider?)
[Pure]
public static Color Parse(string? text, IFormatProvider? formatProvider = null)
Parameters
text
stringThe 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.
formatProvider
IFormatProviderIf specified and not null, will be passed to Parse(ReadOnlySpan<char>, IFormatProvider?).
Returns
Remarks
Exceptions
- ArgumentNullException
If
text
is null.- ArgumentException
If
text
is 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
text
ReadOnlySpan<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.
formatProvider
IFormatProviderOptional 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
text
was 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
utf8Text
ReadOnlySpan<byte>The span of UTF-8 characters to parse.
provider
IFormatProviderAn object that provides culture-specific formatting information about
utf8Text
.
Returns
- Color
The result of parsing
utf8Text
.
Exceptions
- FormatException
utf8Text
is not in the correct format.- OverflowException
utf8Text
is not representable by Color.