Write(value, foreground, background, stdErr) WriteFmt(value, foreground, background, stdErr) WriteLine(value, foreground, background, stdErr, align)
Legend Class Struct Enum Interface Delegate | Constructor Method Property Event Field |
| Static method: void WriteLineFmt(FormattableString, ConsoleColor?, ConsoleColor?, bool, HorizontalTextAlignment)Declarationpublic static void WriteLineFmt(
FormattableString value,
ConsoleColor? foreground = null,
ConsoleColor? background = null,
bool stdErr = false,
HorizontalTextAlignment align = HorizontalTextAlignment.Left
)Summary
Writes the specified FormattableString followed by a newline to the console with console-colored
formatting strings enabled (see remarks). Parameters| FormattableString | value |
Formattable string. You can use an interpolated string literal here. | | ConsoleColor? | foreground |
Default foreground color when an interpolated variable isn’t a ConsoleColoredString or ConsoleColoredChar or a foreground color is unspecified. | | ConsoleColor? | background |
Default background color when an interpolated variable isn’t a ConsoleColoredString or ConsoleColoredChar or a background color is unspecified. | | bool | stdErr | true to print to Standard Error instead of Standard Output. | | HorizontalTextAlignment | align |
Horizontal alignment of the string within the remaining space of the current line. If the string does not fit, it
will be printed as if left-aligned. |
Remarks
When using this method, format strings are expected to be different: -
To color an interpolated value, specify one of K=Black, B=Blue, G=Green, C=Cyan, R=Red, M=Magenta,
Y=Yellow, A=Gray, W=White, or lower-case for dark. Use two characters to specify background color as well
(e.g.
Yb = yellow on dark blue). -
To only background-color an interpolated value, prefix the color code with an
_ (underscore). -
To format a value, prepend the formatting string with a
/ (slash). For example: {0:/X} will
do the same as .ToString("X"). -
To do both color and formatting, specify the color code, then a
/ (slash), then the formatting
string. For example: {0:Yb/X}.
|