Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / ConsoleKeyInfo.cs / 1305376 / ConsoleKeyInfo.cs
using System.Diagnostics.Contracts; // ==++== // // 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")); Contract.EndContractBlock(); _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; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GeneralTransform.cs
- IfJoinedCondition.cs
- LoginView.cs
- EndpointNameMessageFilter.cs
- CodeCommentStatement.cs
- Atom10FormatterFactory.cs
- DatatypeImplementation.cs
- XmlSchemaObjectCollection.cs
- StartUpEventArgs.cs
- KeyGestureValueSerializer.cs
- KnowledgeBase.cs
- CompareValidator.cs
- View.cs
- IApplicationTrustManager.cs
- StringArrayConverter.cs
- DocumentPaginator.cs
- SiteMapDesignerDataSourceView.cs
- LogEntryDeserializer.cs
- ParallelTimeline.cs
- ListenerAdapterBase.cs
- IDQuery.cs
- HostProtectionPermission.cs
- XmlValueConverter.cs
- ExecutionContext.cs
- CoTaskMemHandle.cs
- MatrixTransform.cs
- EnterpriseServicesHelper.cs
- ActivitySurrogateSelector.cs
- ArgumentOutOfRangeException.cs
- RC2CryptoServiceProvider.cs
- CookieParameter.cs
- DictionaryEntry.cs
- SqlDelegatedTransaction.cs
- NavigationProgressEventArgs.cs
- CqlLexerHelpers.cs
- SortQueryOperator.cs
- CreateParams.cs
- ProcessHost.cs
- FormsAuthenticationUserCollection.cs
- EncodingNLS.cs
- XmlSerializerVersionAttribute.cs
- SymmetricKey.cs
- WizardStepBase.cs
- IdentitySection.cs
- IncrementalHitTester.cs
- _LoggingObject.cs
- DetailsViewUpdatedEventArgs.cs
- SerializerProvider.cs
- PropertyOverridesDialog.cs
- ListItem.cs
- OutputCacheSettings.cs
- XsltQilFactory.cs
- DataGridViewDataConnection.cs
- AndCondition.cs
- Mapping.cs
- CodeDomSerializerBase.cs
- Operators.cs
- TextEffect.cs
- QueryContinueDragEventArgs.cs
- MetafileEditor.cs
- RedistVersionInfo.cs
- QueryOperator.cs
- RegexMatchCollection.cs
- DataSourceControlBuilder.cs
- DataGridViewTopRowAccessibleObject.cs
- SimpleHandlerFactory.cs
- OleDbFactory.cs
- RegexWorker.cs
- VirtualizingStackPanel.cs
- ConfigDefinitionUpdates.cs
- StreamGeometryContext.cs
- DbProviderFactoriesConfigurationHandler.cs
- WindowsGraphicsCacheManager.cs
- PageParserFilter.cs
- WorkflowMarkupElementEventArgs.cs
- CustomAssemblyResolver.cs
- Encoder.cs
- ObjectStateFormatter.cs
- SqlNotificationRequest.cs
- RpcCryptoContext.cs
- WindowsToolbarAsMenu.cs
- ClientEventManager.cs
- DBCSCodePageEncoding.cs
- StylusButtonEventArgs.cs
- WinFormsUtils.cs
- HostedHttpRequestAsyncResult.cs
- SubMenuStyle.cs
- TabletCollection.cs
- CodeTypeOfExpression.cs
- BamlLocalizableResourceKey.cs
- DropSource.cs
- CapabilitiesPattern.cs
- ItemsControlAutomationPeer.cs
- SafeHandles.cs
- ObjectDataSourceSelectingEventArgs.cs
- OpenTypeLayout.cs
- ConfigurationElementProperty.cs
- XmlNotation.cs
- CngKeyCreationParameters.cs
- MessageSecurityOverTcpElement.cs