ConsoleHelper

Ecng.Common

Provides helper methods for writing colored messages to the console and reading secure passwords.

方法

ConsoleError
public static void ConsoleError(string message)
ConsoleHelper.ConsoleError(message)

Writes an error message to the console using the predefined error color.

message
The error message to write.
ConsoleError
public static void ConsoleError(Exception ex)
ConsoleHelper.ConsoleError(ex)

Writes an exception to the console using the predefined error color.

ex
The exception to write.
ConsoleInfo
public static void ConsoleInfo(string message)
ConsoleHelper.ConsoleInfo(message)

Writes an information message to the console.

message
The message to write.
ConsoleSuccess
public static void ConsoleSuccess(string message)
ConsoleHelper.ConsoleSuccess(message)

Writes a success message to the console using the predefined success color.

message
The success message to write.
ConsoleWarning
public static void ConsoleWarning(string message)
ConsoleHelper.ConsoleWarning(message)

Writes a warning message to the console using the predefined warning color.

message
The warning message to write.
ConsoleWithColor
public static void ConsoleWithColor(string message, ConsoleColor color)
ConsoleHelper.ConsoleWithColor(message, color)

Writes a message to the console with the specified color.

message
The message to write.
color
The color to use for the message.
ConsoleWithColor
public static void ConsoleWithColor(Action handler, ConsoleColor color)
ConsoleHelper.ConsoleWithColor(handler, color)

Executes the provided action while displaying console output in the specified color.

handler
The action to execute.
color
The color to use for the console output.
ReadPassword
public static SecureString ReadPassword()
result = ConsoleHelper.ReadPassword()

Reads a password from the console without displaying it, outputting a masked version.

返回值: A SecureString that contains the password.

字段

Error
public static ConsoleColor Error
value = ConsoleHelper.Error

Gets or sets the color used to display error messages.

Info
public static ConsoleColor Info
value = ConsoleHelper.Info

Gets or sets the color used to display information messages.

Success
public static ConsoleColor Success
value = ConsoleHelper.Success

Gets or sets the color used to display success messages.

Warning
public static ConsoleColor Warning
value = ConsoleHelper.Warning

Gets or sets the color used to display warning messages.