ConsoleKeyInfo::KeyChar Property

 

Gets the Unicode character represented by the current ConsoleKeyInfo object.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
property wchar_t KeyChar {
	wchar_t get();
}

Property Value

Type: System::Char

An object that corresponds to the console key represented by the current ConsoleKeyInfo object.

If the key pressed does not map to a Unicode character (for example, if the user presses the F1 key or the Home key), the value of the KeyChar property is \U0000.

The following example uses the KeyChar property to add the characters input by the user into a string. The example ignores special keys other than ENTER, ESC, and BACKSPACE.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: