Class ConsoleHelper
Provides helper methods for writing colored messages to the console and reading secure passwords.
public static class ConsoleHelper
- Inheritance
-
ConsoleHelper
- Inherited Members
Fields
Error
Gets or sets the color used to display error messages.
public static ConsoleColor Error
Field Value
Info
Gets or sets the color used to display information messages.
public static ConsoleColor Info
Field Value
Success
Gets or sets the color used to display success messages.
public static ConsoleColor Success
Field Value
Warning
Gets or sets the color used to display warning messages.
public static ConsoleColor Warning
Field Value
Methods
ConsoleError(string)
Writes an error message to the console using the predefined error color.
public static void ConsoleError(this string message)
Parameters
messagestringThe error message to write.
ConsoleInfo(string)
Writes an information message to the console.
public static void ConsoleInfo(this string message)
Parameters
messagestringThe message to write.
ConsoleSuccess(string)
Writes a success message to the console using the predefined success color.
public static void ConsoleSuccess(this string message)
Parameters
messagestringThe success message to write.
ConsoleWarning(string)
Writes a warning message to the console using the predefined warning color.
public static void ConsoleWarning(this string message)
Parameters
messagestringThe warning message to write.
ConsoleWithColor(Action, ConsoleColor)
Executes the provided action while displaying console output in the specified color.
public static void ConsoleWithColor(this Action handler, ConsoleColor color)
Parameters
handlerActionThe action to execute.
colorConsoleColorThe color to use for the console output.
Exceptions
- ArgumentNullException
Thrown when the handler is null.
ConsoleWithColor(string, ConsoleColor)
Writes a message to the console with the specified color.
public static void ConsoleWithColor(this string message, ConsoleColor color)
Parameters
messagestringThe message to write.
colorConsoleColorThe color to use for the message.
ReadPassword()
Reads a password from the console without displaying it, outputting a masked version.
public static SecureString ReadPassword()
Returns
- SecureString
A SecureString that contains the password.