Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / ConsoleKeyInfo.cs / 1 / ConsoleKeyInfo.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================================== ** ** Class: ConsoleKeyInfo ** ** ** Purpose: This value type represents a single key press, with modifier keys ** like Alt, Control, and Shift. ** ** =============================================================================*/ namespace System { [Serializable] public struct ConsoleKeyInfo { private char _keyChar; private ConsoleKey _key; private ConsoleModifiers _mods; public ConsoleKeyInfo(char keyChar, ConsoleKey key, bool shift, bool alt, bool control) { // Limit ConsoleKey values to 0 to 255, but don't check whether the // key is a valid value in our ConsoleKey enum. There are a few // values in that enum that we didn't define, and reserved keys // that might start showing up on keyboards in a few years. if (((int)key) < 0 || ((int)key) > 255) throw new ArgumentOutOfRangeException("key", Environment.GetResourceString("ArgumentOutOfRange_ConsoleKey")); _keyChar = keyChar; _key = key; _mods = 0; if (shift) _mods |= ConsoleModifiers.Shift; if (alt) _mods |= ConsoleModifiers.Alt; if (control) _mods |= ConsoleModifiers.Control; } public char KeyChar { get { return _keyChar; } } public ConsoleKey Key { get { return _key; } } public ConsoleModifiers Modifiers { get { return _mods; } } public override bool Equals(Object value) { if (value is ConsoleKeyInfo) return Equals((ConsoleKeyInfo)value); else return false; } public bool Equals(ConsoleKeyInfo obj) { return obj._keyChar == _keyChar && obj._key == _key && obj._mods == _mods; } public static bool operator ==(ConsoleKeyInfo a, ConsoleKeyInfo b) { return a.Equals(b); } public static bool operator !=(ConsoleKeyInfo a, ConsoleKeyInfo b) { return !(a == b); } public override int GetHashCode() { return (int)_keyChar | (int) _mods; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ToolStripOverflowButton.cs
- RemoteWebConfigurationHost.cs
- MessageQueuePermission.cs
- Span.cs
- XPathNodePointer.cs
- StyleBamlRecordReader.cs
- SafeCertificateStore.cs
- WorkflowNamespace.cs
- ISO2022Encoding.cs
- SqlProfileProvider.cs
- PathFigureCollection.cs
- TextFormatterImp.cs
- XmlSerializer.cs
- BufferModesCollection.cs
- DetailsViewDeleteEventArgs.cs
- AssertFilter.cs
- ReturnEventArgs.cs
- InstanceData.cs
- UriSectionReader.cs
- DataRelationCollection.cs
- FileRecordSequenceCompletedAsyncResult.cs
- cookieexception.cs
- StickyNote.cs
- Processor.cs
- BuildProvider.cs
- Font.cs
- ClosableStream.cs
- PageWrapper.cs
- BinaryUtilClasses.cs
- DataExpression.cs
- ExtenderControl.cs
- SettingsBindableAttribute.cs
- HijriCalendar.cs
- FixedSOMTableRow.cs
- ObjectPersistData.cs
- DllNotFoundException.cs
- ReflectEventDescriptor.cs
- TcpHostedTransportConfiguration.cs
- PrintDialog.cs
- ControlBindingsCollection.cs
- KeyInterop.cs
- ViewPort3D.cs
- OutputCacheSettings.cs
- DecoratedNameAttribute.cs
- ExpandoObject.cs
- HashMembershipCondition.cs
- MetadataResolver.cs
- ExpressionBuilderCollection.cs
- DBSchemaTable.cs
- GZipStream.cs
- ObjectQueryProvider.cs
- RoleManagerEventArgs.cs
- SByteStorage.cs
- Point4D.cs
- DataGridViewTopRowAccessibleObject.cs
- HttpDigestClientElement.cs
- SelectorAutomationPeer.cs
- XmlWhitespace.cs
- TemplateAction.cs
- TargetControlTypeAttribute.cs
- ContextBase.cs
- DataFormat.cs
- KeyTime.cs
- TrackingLocationCollection.cs
- Material.cs
- ExtendedPropertyDescriptor.cs
- HeaderPanel.cs
- SchemaImporterExtensionElementCollection.cs
- Keywords.cs
- OrderedEnumerableRowCollection.cs
- DrawingBrush.cs
- CellParaClient.cs
- KeysConverter.cs
- TypeUnloadedException.cs
- BindingExpression.cs
- ElementMarkupObject.cs
- GeometryHitTestParameters.cs
- DataGridViewColumnHeaderCell.cs
- Message.cs
- ManipulationPivot.cs
- TagNameToTypeMapper.cs
- DefaultAsyncDataDispatcher.cs
- BrowserCapabilitiesCompiler.cs
- HttpCachePolicy.cs
- BuildProvider.cs
- ReflectionTypeLoadException.cs
- Encoding.cs
- PathTooLongException.cs
- TextRangeEditLists.cs
- ProfileProvider.cs
- AbstractSvcMapFileLoader.cs
- DynamicMethod.cs
- CodeSnippetStatement.cs
- GregorianCalendar.cs
- DataSourceComponent.cs
- PropertyRef.cs
- ConfigurationElementCollection.cs
- PropertyPanel.cs
- DataTableExtensions.cs
- XmlSchemaInfo.cs