Class MessageInColor
Console.Write and Console.WriteLine methods that write in living color.
Inheritance
Namespace: WizardWrx.ConsoleStreams
Assembly: WizardWrx.ConsoleStreams.dll
Syntax
public class MessageInColor : object
Remarks
There are two identical sets of methods.
Static methods write text in your choice of foreground and background colors, then revert the console colors to their initial values (that is, the values they had when the program loaded).
Instance methods go a step further, by maintaining a record of the current colors, so that the colors can progress through a range, without reverting to the initial colors.
For each overload of Console.Write, there are corresponding static and instance methods. The only difference in their signatures is that these methods specify a foreground color and a background color, followed by the same arguments that would apply to the corresponding overload of the Console.Write method.
Constructors
| Improve this Doc View SourceMessageInColor()
Constructing an instance saves the current foreground and background colors into two pairs of read only ConsoleColor properties. Methods facilitate changing one or both colors, while retaining the original colors in the other two ConsoleColor properties, which are never changed after the class instance comes into being.
Declaration
public MessageInColor()
Remarks
This method is provided to facilitate construction of a List or other sortable collection of MessageInColor objects, and allows for a future version of this class to be exposed to COM.
MessageInColor(ConsoleColor, ConsoleColor)
This constructor creates an instance with its foreground and background colors properties set to the specified ConsoleColor values, which presumably differ from the initial foreground and background colors.
Declaration
public MessageInColor(ConsoleColor pclrTextForeColor, ConsoleColor pclrTextBackColor)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrTextForeColor | Specify the ConsoleColor property to use as the text (foreground) color in generated messages. |
ConsoleColor | pclrTextBackColor | Specify the ConsoleColor property to use as the background color in generated messages. |
Properties
| Improve this Doc View SourceMessageBackgroundColor
Gets or sets the Console.BackgroundColor to use for messages generated by the instance Write and WriteLine methods.
Declaration
public ConsoleColor MessageBackgroundColor { get; set; }
Property Value
Type | Description |
---|---|
ConsoleColor |
MessageForegroundColor
Gets or sets the Console.ForegroundColor to use for messages generated by the instance Write and WriteLine methods.
Declaration
public ConsoleColor MessageForegroundColor { get; set; }
Property Value
Type | Description |
---|---|
ConsoleColor |
OriginalBackgroundColor
Gets the Console.BackgroundColor that was in force when the instance was constructed.
Declaration
public ConsoleColor OriginalBackgroundColor { get; }
Property Value
Type | Description |
---|---|
ConsoleColor |
OriginalForegroundColor
Gets the Console.ForegroundColor that was in force when the instance was constructed.
Declaration
public ConsoleColor OriginalForegroundColor { get; }
Property Value
Type | Description |
---|---|
ConsoleColor |
Methods
| Improve this Doc View SourceRGBWrite(ConsoleColor, ConsoleColor, Boolean)
Write the string representation of a bool (Boolean) variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, bool value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Boolean | value | Specify the Boolean value to display. |
RGBWrite(ConsoleColor, ConsoleColor, Char)
Write the string representation of a char (a Unicode character).
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, char value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Char | value | Specify the Unicode character to display. |
RGBWrite(ConsoleColor, ConsoleColor, Char[])
Write the string representation of a character array.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, char[] buffer)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Char[] | buffer | Specify the array of Unicode characters to display. |
RGBWrite(ConsoleColor, ConsoleColor, Char[], Int32, Int32)
Write a formatted message that includes a range of characters taken from an array of Unicode characters.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Char[] | buffer | Extract characters from this array of Unicode characters. |
System.Int32 | index | Subscript of character to substitute for token {0} in format. |
System.Int32 | count | Number of characters from buffer to substitute into string, which must contain at least count - 1 substitution tokens. |
RGBWrite(ConsoleColor, ConsoleColor, Decimal)
Write the string representation of a decimal variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, decimal value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Decimal | value | Specify the decimal value to display. |
RGBWrite(ConsoleColor, ConsoleColor, Double)
Write the string representation of a double precision variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, double value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Double | value | Specify the double precision value to display. |
RGBWrite(ConsoleColor, ConsoleColor, Int32)
Write the string representation of an integer variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, int value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Int32 | value | Specify the integer value to display. |
RGBWrite(ConsoleColor, ConsoleColor, Int64)
Write the string representation of a long integer variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, long value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Int64 | value | Specify the long integer value to display. |
RGBWrite(ConsoleColor, ConsoleColor, Object)
Write the string representation of a generic Object variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, object value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Object | value | Specify the object value to display. |
RGBWrite(ConsoleColor, ConsoleColor, Single)
Write the string representation of a floating point variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, float value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Single | value | Specify the floating point value to display. |
RGBWrite(ConsoleColor, ConsoleColor, String)
Write a string variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | value | Specify the string value to display. |
RGBWrite(ConsoleColor, ConsoleColor, String, Object)
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may include at most one substitution token. |
System.Object | arg0 | Replace the substition token with the string representation of this generic object. |
RGBWrite(ConsoleColor, ConsoleColor, String, Object, Object)
Write a formatted message that includes up to two substitution tokens.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0, object arg1)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contain up to two substition tokens, {0} and {1}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
RGBWrite(ConsoleColor, ConsoleColor, String, Object, Object, Object)
Write a formatted message that includes up to three substitution tokens.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0, object arg1, object arg2)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contain up to 3 substition tokens, {0}, {1}, and {2}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
RGBWrite(ConsoleColor, ConsoleColor, String, Object, Object, Object, Object)
Write a formatted message that includes up to four substitution tokens.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0, object arg1, object arg2, object arg3)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contain up to 4 substition tokens, {0}, {1}, {2}, and {3}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
System.Object | arg3 | The default string representation of this generic Object variable is substituted into format for token {3}. |
RGBWrite(ConsoleColor, ConsoleColor, String, Object[])
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, params object[] arg)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contains substitution tokens for each object in an array of generic Object variables. |
System.Object[] | arg | Substitute elements from this array of generic Object variables into the format string, replacing tokens with the element whose subscript is the number within its brackets. |
RGBWrite(ConsoleColor, ConsoleColor, UInt32)
Write the string representation of a uint (unsigned integer) variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, uint value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.UInt32 | value | Specify the uint (unsigned integer) value to display. |
RGBWrite(ConsoleColor, ConsoleColor, UInt64)
Write the string representation of a ulong (unsigned long integer) variable.
Declaration
public static void RGBWrite(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, ulong value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.UInt64 | value | Specify the ulong (unsigned long integer) value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Boolean)
Write the string representation of a bool (Boolean) variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, bool value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Boolean | value | Specify the Boolean value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Char)
Write the string representation of a char (a Unicode character).
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, char value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Char | value | Specify the Unicode character to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Char[])
Write the string representation of a character array.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, char[] buffer)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Char[] | buffer | Specify the array of Unicode characters to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Char[], Int32, Int32)
Write a formatted message that includes a range of characters taken from an array of Unicode characters.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Char[] | buffer | Extract characters from this array of Unicode characters. |
System.Int32 | index | Subscript of character to substitute for token {0} in format. |
System.Int32 | count | Number of characters from buffer to substitute into string, which must contain at least count - 1 substitution tokens. |
RGBWriteLine(ConsoleColor, ConsoleColor, Decimal)
Write the string representation of a decimal variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, decimal value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Decimal | value | Specify the decimal value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Double)
Write the string representation of a double precision variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, double value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Double | value | Specify the double precision value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Int32)
Write the string representation of an integer variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, int value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Int32 | value | Specify the integer value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Int64)
Write the string representation of a long integer variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, long value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Int64 | value | Specify the long integer value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Object)
Write the string representation of a generic Object variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, object value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Object | value | Specify the object value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, Single)
Write the string representation of a floating point variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, float value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.Single | value | Specify the floating point value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, String)
Write a string variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | value | Specify the string value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, String, Object)
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may include at most one substitution token. |
System.Object | arg0 | Replace the substition token with the string representation of this generic object. |
RGBWriteLine(ConsoleColor, ConsoleColor, String, Object, Object)
Write a formatted message that includes up to two substitution tokens.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0, object arg1)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contain up to two substition tokens, {0} and {1}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
RGBWriteLine(ConsoleColor, ConsoleColor, String, Object, Object, Object)
Write a formatted message that includes up to three substitution tokens.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0, object arg1, object arg2)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contain up to 3 substition tokens, {0}, {1}, and {2}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
RGBWriteLine(ConsoleColor, ConsoleColor, String, Object, Object, Object, Object)
Write a formatted message that includes up to four substitution tokens.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, object arg0, object arg1, object arg2, object arg3)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contain up to 4 substition tokens, {0}, {1}, {2}, and {3}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
System.Object | arg3 | The default string representation of this generic Object variable is substituted into format for token {3}. |
RGBWriteLine(ConsoleColor, ConsoleColor, String, Object[])
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, string format, params object[] arg)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.String | format | Use this string as the message template, which may contains substitution tokens for each object in an array of generic Object variables. |
System.Object[] | arg | Substitute elements from this array of generic Object variables into the format string, replacing tokens with the element whose subscript is the number within its brackets. |
RGBWriteLine(ConsoleColor, ConsoleColor, UInt32)
Write the string representation of a uint (unsigned integer) variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, uint value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.UInt32 | value | Specify the uint (unsigned integer) value to display. |
RGBWriteLine(ConsoleColor, ConsoleColor, UInt64)
Write the string representation of a ulong (unsigned long integer) variable.
Declaration
public static void RGBWriteLine(ConsoleColor pclrForeColor, ConsoleColor pclrBackColor, ulong value)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | pclrForeColor | Specify the ConsoleColor to use for the foreground (text). |
ConsoleColor | pclrBackColor | Specify the ConsoleColor to use for the background. |
System.UInt64 | value | Specify the ulong (unsigned long integer) value to display. |
SafeConsoleClear()
Use this method as a non-throwing replacement for Console.Clear, which throws an System.IO.IOException exception if the standard output stream is redirected. This catches that exception and eats it unless the user enables logging of all exceptions, typically in a testing scenario.
Declaration
public static void SafeConsoleClear()
Remarks
Comparing the HResult to a local constant, E_HANDLE, means that the error test works correctly in any locale.
Thankfully, Microsoft came to their senses, and made the HResult visible in later frameworks. Meanwhile, I've found a workaround that should do the job in code that targets .NET Framework 3.5.
ToString()
Override the default ToString method inherited from the base class (object) to display the most significant properties, the text, or foreground, and background colors set by the constructor, followed by the fully qualified type name.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | The return value is a string of the following format. {Text = ConsoleColorText, Background = BackroundColor} WizardWrx.ConsoleStreams.MessageInColor |
Remarks
Though this method could have easily been implemented inline, using the shared message template, moving the implementation out of line affords the flexibility to rearrange the display consistently, even if that requires the properties to be reordered.
Write(Boolean)
Write the string representation of a bool (Boolean) variable.
Declaration
public void Write(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | Specify the Boolean value to display. |
Write(Char)
Write the string representation of a char (a Unicode character).
Declaration
public void Write(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | Specify the Unicode character to display. |
Write(Char[])
Write the string representation of a character array.
Declaration
public void Write(char[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | buffer | Specify the array of Unicode characters to display. |
Write(Char[], Int32, Int32)
Write a formatted message that includes a range of characters taken from an array of Unicode characters.
Declaration
public void Write(char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | buffer | Extract characters from this array of Unicode characters. |
System.Int32 | index | Subscript of character to substitute for token {0} in format. |
System.Int32 | count | Number of characters from buffer to substitute into string, which must contain at least count - 1 substitution tokens. |
Write(Decimal)
Write the string representation of a decimal variable.
Declaration
public void Write(decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | value | Specify the decimal value to display. |
Write(Double)
Write the string representation of a double precision variable.
Declaration
public void Write(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | Specify the double precision value to display. |
Write(Int32)
Write the string representation of an integer variable.
Declaration
public void Write(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | Specify the integer value to display. |
Write(Int64)
Write the string representation of a long integer variable.
Declaration
public void Write(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | Specify the long integer value to display. |
Write(Object)
Write the string representation of a generic Object variable.
Declaration
public void Write(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Specify the object value to display. |
Write(Single)
Write the string representation of a floating point variable.
Declaration
public void Write(float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | Specify the floating point value to display. |
Write(String)
Write a string variable.
Declaration
public void Write(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | Specify the string value to display. |
Write(String, Object)
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public void Write(string format, object arg0)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may include at most one substitution token. |
System.Object | arg0 | Replace the substition token with the string representation of this generic object. |
Write(String, Object, Object)
Write a formatted message that includes up to two substitution tokens.
Declaration
public void Write(string format, object arg0, object arg1)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contain up to two substition tokens, {0} and {1}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
Write(String, Object, Object, Object)
Write a formatted message that includes up to three substitution tokens.
Declaration
public void Write(string format, object arg0, object arg1, object arg2)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contain up to 3 substition tokens, {0}, {1}, and {2}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
Write(String, Object, Object, Object, Object)
Write a formatted message that includes up to four substitution tokens.
Declaration
public void Write(string format, object arg0, object arg1, object arg2, object arg3)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contain up to 4 substition tokens, {0}, {1}, {2}, and {3}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
System.Object | arg3 | The default string representation of this generic Object variable is substituted into format for token {3}. |
Write(String, Object[])
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public void Write(string format, params object[] arg)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contains substitution tokens for each object in an array of generic Object variables. |
System.Object[] | arg | Substitute elements from this array of generic Object variables into the format string, replacing tokens with the element whose subscript is the number within its brackets. |
Write(UInt32)
Write the string representation of a uint (unsigned integer) variable.
Declaration
public void Write(uint value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value | Specify the uint (unsigned integer) value to display. |
Write(UInt64)
Write the string representation of a ulong (unsigned long integer) variable.
Declaration
public void Write(ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value | Specify the ulong (unsigned long integer) value to display. |
WriteLine(Boolean)
Write the string representation of a bool (Boolean) variable.
Declaration
public void WriteLine(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | Specify the Boolean value to display. |
WriteLine(Char)
Write the string representation of a char (a Unicode character).
Declaration
public void WriteLine(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | Specify the Unicode character to display. |
WriteLine(Char[])
Write the string representation of a character array.
Declaration
public void WriteLine(char[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | buffer | Specify the array of Unicode characters to display. |
WriteLine(Char[], Int32, Int32)
Write a formatted message that includes a range of characters taken from an array of Unicode characters.
Declaration
public void WriteLine(char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | buffer | Extract characters from this array of Unicode characters. |
System.Int32 | index | Subscript of character to substitute for token {0} in format. |
System.Int32 | count | Number of characters from buffer to substitute into string, which must contain at least count - 1 substitution tokens. |
WriteLine(Decimal)
Write the string representation of a decimal variable.
Declaration
public void WriteLine(decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | value | Specify the decimal value to display. |
WriteLine(Double)
Write the string representation of a double precision variable.
Declaration
public void WriteLine(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | Specify the double precision value to display. |
WriteLine(Int32)
Write the string representation of an integer variable.
Declaration
public void WriteLine(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | Specify the integer value to display. |
WriteLine(Int64)
Write the string representation of a long integer variable.
Declaration
public void WriteLine(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | Specify the long integer value to display. |
WriteLine(Object)
Write the string representation of a generic Object variable.
Declaration
public void WriteLine(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Specify the object value to display. |
WriteLine(Single)
Write the string representation of a floating point variable.
Declaration
public void WriteLine(float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | Specify the floating point value to display. |
WriteLine(String)
Write a string variable.
Declaration
public void WriteLine(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | Specify the string value to display. |
WriteLine(String, Object)
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public void WriteLine(string format, object arg0)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may include at most one substitution token. |
System.Object | arg0 | Replace the substition token with the string representation of this generic object. |
WriteLine(String, Object, Object)
Write a formatted message that includes up to two substitution tokens.
Declaration
public void WriteLine(string format, object arg0, object arg1)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contain up to two substition tokens, {0} and {1}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
WriteLine(String, Object, Object, Object)
Write a formatted message that includes up to three substitution tokens.
Declaration
public void WriteLine(string format, object arg0, object arg1, object arg2)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contain up to 3 substition tokens, {0}, {1}, and {2}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
WriteLine(String, Object, Object, Object, Object)
Write a formatted message that includes up to four substitution tokens.
Declaration
public void WriteLine(string format, object arg0, object arg1, object arg2, object arg3)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contain up to 4 substition tokens, {0}, {1}, {2}, and {3}. |
System.Object | arg0 | The default string representation of this generic Object variable is substituted into format for token {0}. |
System.Object | arg1 | The default string representation of this generic Object variable is substituted into format for token {1}. |
System.Object | arg2 | The default string representation of this generic Object variable is substituted into format for token {2}. |
System.Object | arg3 | The default string representation of this generic Object variable is substituted into format for token {3}. |
WriteLine(String, Object[])
Write a formatted message that includes the string representation of an generic object variable.
Declaration
public void WriteLine(string format, params object[] arg)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Use this string as the message template, which may contains substitution tokens for each object in an array of generic Object variables. |
System.Object[] | arg | Substitute elements from this array of generic Object variables into the format string, replacing tokens with the element whose subscript is the number within its brackets. |
WriteLine(UInt32)
Write the string representation of a uint (unsigned integer) variable.
Declaration
public void WriteLine(uint value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value | Specify the uint (unsigned integer) value to display. |
WriteLine(UInt64)
Write the string representation of a ulong (unsigned long integer) variable.
Declaration
public void WriteLine(ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value | Specify the ulong (unsigned long integer) value to display. |