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
- ValueSerializerAttribute.cs
- CompiledIdentityConstraint.cs
- DataStorage.cs
- SqlError.cs
- DateTimeConstantAttribute.cs
- Aggregates.cs
- ViewStateException.cs
- ToolStripLocationCancelEventArgs.cs
- RegexCapture.cs
- IndexedEnumerable.cs
- MdImport.cs
- Hex.cs
- MissingSatelliteAssemblyException.cs
- DataColumnPropertyDescriptor.cs
- FormViewCommandEventArgs.cs
- SecurityTraceRecordHelper.cs
- StoreAnnotationsMap.cs
- JpegBitmapDecoder.cs
- ClientTargetSection.cs
- CultureInfo.cs
- ValuePattern.cs
- QueryCoreOp.cs
- CorrelationTokenTypeConvertor.cs
- IItemProperties.cs
- HwndAppCommandInputProvider.cs
- DataGridRelationshipRow.cs
- PeerNodeAddress.cs
- ProtocolException.cs
- IntSumAggregationOperator.cs
- ScrollViewer.cs
- ValuePattern.cs
- EventProvider.cs
- CrossContextChannel.cs
- ResolveCriteria11.cs
- ClientProxyGenerator.cs
- CodePageUtils.cs
- TabControlDesigner.cs
- DBDataPermissionAttribute.cs
- DesignerHierarchicalDataSourceView.cs
- EventPropertyMap.cs
- HttpClientCertificate.cs
- WebHeaderCollection.cs
- ResXResourceReader.cs
- StickyNoteAnnotations.cs
- SchemaCollectionPreprocessor.cs
- HttpCacheVaryByContentEncodings.cs
- TextWriter.cs
- RewritingPass.cs
- CheckableControlBaseAdapter.cs
- _SSPIWrapper.cs
- VisualTreeHelper.cs
- RenderOptions.cs
- ByteAnimationBase.cs
- Point.cs
- TransactionWaitAsyncResult.cs
- NonParentingControl.cs
- DataViewListener.cs
- BuildResult.cs
- ButtonStandardAdapter.cs
- HtmlElementCollection.cs
- ObjectIDGenerator.cs
- UDPClient.cs
- DocumentApplication.cs
- ComboBox.cs
- GridItemCollection.cs
- BaseTemplateCodeDomTreeGenerator.cs
- Converter.cs
- InputElement.cs
- figurelength.cs
- XmlSchemas.cs
- ManualWorkflowSchedulerService.cs
- DataSet.cs
- XamlVector3DCollectionSerializer.cs
- EmbeddedMailObjectsCollection.cs
- ImageBrush.cs
- HttpCapabilitiesSectionHandler.cs
- FirewallWrapper.cs
- BitStream.cs
- TrustSection.cs
- ExpressionPrefixAttribute.cs
- UserControlAutomationPeer.cs
- AsymmetricKeyExchangeDeformatter.cs
- FileDialog_Vista_Interop.cs
- FontUnit.cs
- EmptyReadOnlyDictionaryInternal.cs
- SettingsBase.cs
- DocumentOrderComparer.cs
- KeyValueInternalCollection.cs
- RijndaelCryptoServiceProvider.cs
- ExtensionsSection.cs
- CodeTypeOfExpression.cs
- TextFormatterContext.cs
- ObjectViewEntityCollectionData.cs
- RtType.cs
- FixedTextView.cs
- ScaleTransform.cs
- SoapObjectReader.cs
- DateTimeUtil.cs
- OutputCacheSettings.cs
- CopyEncoder.cs