Cinchoo framework provides one another helper class, ChoConsole. It is a static class, exposes lot of methods to help to build Console application.
1. Add reference to Cinchoo.Core.dll assembly
2. Namespace Cinchoo.Core.Shell.Console
Below are the following methods
Write() Overloads:
This class provides various Write methods to write values to application console window. Here I’m going to walk over one set of Write methods,
public static void Write(string msg); public static void Write(string msg, ConsoleColor foregroundColor); public static void Write(string msg, ConsoleColor foregroundColor, ConsoleColor backgroundColor); public static void Write(string msg, ChoPoint cursorLocation); public static void Write(string msg, ChoPoint cursorLocation, ConsoleColor foregroundColor, ConsoleColor backgroundColor); public static void Write(string msg, int cursorLeft, int cursorTop); public static void Write(string msg, int cursorLeft, int cursorTop, ConsoleColor foregroundColor, ConsoleColor backgroundColor);
There are number other Write overloads to handle other datatype variables (int, long, char etc). Please explore yourself.
WriteLine() Overloads:
This class provides various WriteLine methods to write values followed by NewLine to application console window. Here I’m going to walk over one set of WriteLine methods,
public static void WriteLine(string msg); public static void WriteLine(string msg, ConsoleColor foregroundColor); public static void WriteLine(string msg, ConsoleColor foregroundColor, ConsoleColor backgroundColor); public static void WriteLine(string msg, ChoPoint cursorLocation); public static void WriteLine(string msg, ChoPoint cursorLocation, ConsoleColor foregroundColor, ConsoleColor backgroundColor); public static void WriteLine(string msg, int cursorLeft, int cursorTop); public static void WriteLine(string msg, int cursorLeft, int cursorTop, ConsoleColor foregroundColor, ConsoleColor backgroundColor);
There are number other WriteLine overloads to handle other datatype variables (int, long, char etc). Please explore yourself.
Pause() Overloads:
This method writes the default/specified string value to the standard output stream. Reads the next character from the standard input stream.
public static void Pause(); public static void Pause(string msg);
PauseLine() Overloads:
This method writes the default/specified string value, followed by the current line terminator, to the standard output stream. Reads the next character from the standard input stream.
public static void PauseLine(); public static void PauseLine(string msg);
Read() Overloads:
This method reads the next character from the standard input stream either within the specified timeout period or infinity.
public static int Read(); public static int Read(int timeoutInMilliSeconds); public static int Read(int timeoutInMilliSeconds, int? defaultValue); public static int Read(int timeoutInMilliSeconds, int? defaultValue, string errMsg)
ReadLine() Overloads:
This method reads the next line of characters from the standard input stream either within the specified timeout period or infinity.
public static int ReadLine(); public static int ReadLine(int timeoutInMilliSeconds); public static int ReadLine(int timeoutInMilliSeconds, int? defaultValue); public static int ReadLine(int timeoutInMilliSeconds, int? defaultValue, string errMsg)
ReadKey() Overloads:
This method reads the next character from the standard input stream either within the specified timeout period or infinity.
public static ConsoleKeyInfo ReadKey(); public static ConsoleKeyInfo ReadKey(int timeoutInMilliSeconds); public static ConsoleKeyInfo ReadKey(int timeoutInMilliSeconds, int? defaultValue); public static ConsoleKeyInfo ReadKey(int timeoutInMilliSeconds, int? defaultValue, string errMsg)
ReadPassword() Overloads:
This method reads the next line of characters from the standard input stream. Typed characters will be masked with maskChar in the console window.
public static string ReadPassword(); public static string ReadPassword(int maxLength); public static string ReadPassword(char maskChar, int maxLength);
Happy coding!!!