Code:
/ FX-1434 / FX-1434 / 1.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
- CultureInfo.cs
- RemoteHelper.cs
- RightsManagementEncryptedStream.cs
- TrackingMemoryStreamFactory.cs
- IconConverter.cs
- ExtractedStateEntry.cs
- SystemInformation.cs
- MediaElementAutomationPeer.cs
- RegexTree.cs
- TextDecorationLocationValidation.cs
- OuterGlowBitmapEffect.cs
- xmlformatgeneratorstatics.cs
- TextEmbeddedObject.cs
- TreeIterators.cs
- ItemContainerGenerator.cs
- ToolStripContentPanelDesigner.cs
- VisualBrush.cs
- XmlDocumentFragment.cs
- ListViewInsertEventArgs.cs
- ProviderConnectionPointCollection.cs
- GridViewColumnHeaderAutomationPeer.cs
- WebHttpElement.cs
- Error.cs
- SharedPerformanceCounter.cs
- LoginCancelEventArgs.cs
- TraceEventCache.cs
- SqlDataRecord.cs
- TextDecorationCollectionConverter.cs
- HyperLinkDataBindingHandler.cs
- SystemThemeKey.cs
- OrderedDictionary.cs
- FixedSOMTableCell.cs
- PageContentCollection.cs
- WebPartMenuStyle.cs
- PropertyDescriptorGridEntry.cs
- ReferencedAssembly.cs
- SymDocumentType.cs
- ParseHttpDate.cs
- InvariantComparer.cs
- CodeDirectionExpression.cs
- externdll.cs
- ConfigXmlCDataSection.cs
- DependencyPropertyChangedEventArgs.cs
- FileVersion.cs
- TypeBuilderInstantiation.cs
- Native.cs
- Oid.cs
- ContextBase.cs
- WebHttpElement.cs
- ScrollChrome.cs
- TypeUtils.cs
- PreDigestedSignedInfo.cs
- CriticalHandle.cs
- Token.cs
- Comparer.cs
- CurrentTimeZone.cs
- SByte.cs
- ListBindingHelper.cs
- GorillaCodec.cs
- DetailsViewPageEventArgs.cs
- UpdateException.cs
- EncodingInfo.cs
- TreeViewImageIndexConverter.cs
- XmlHierarchicalEnumerable.cs
- DrawingBrush.cs
- EndEvent.cs
- PermissionSetTriple.cs
- ConfigurationStrings.cs
- XmlReaderDelegator.cs
- QuaternionIndependentAnimationStorage.cs
- CodeDomConfigurationHandler.cs
- RequestCachePolicyConverter.cs
- UnderstoodHeaders.cs
- ScriptResourceInfo.cs
- ImageFormatConverter.cs
- UriScheme.cs
- HtmlCalendarAdapter.cs
- DecoratedNameAttribute.cs
- AnonymousIdentificationSection.cs
- PageOrientation.cs
- XmlSchemaIdentityConstraint.cs
- LayoutEngine.cs
- ObjectParameterCollection.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- BitmapPalettes.cs
- ChangeProcessor.cs
- CharKeyFrameCollection.cs
- BuilderInfo.cs
- BaseValidator.cs
- XmlSerializationGeneratedCode.cs
- ColorBlend.cs
- VisualTarget.cs
- WebPartZoneBase.cs
- ConfigXmlComment.cs
- IIS7UserPrincipal.cs
- SessionChannels.cs
- GenericAuthenticationEventArgs.cs
- ListenerBinder.cs
- DbException.cs
- TimeSpanConverter.cs