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
- DoWorkEventArgs.cs
- TypeNameConverter.cs
- DataGridViewCheckBoxCell.cs
- HtmlEncodedRawTextWriter.cs
- Condition.cs
- ListControlBoundActionList.cs
- AccessDataSource.cs
- Speller.cs
- ScriptMethodAttribute.cs
- TextDecorationUnitValidation.cs
- AxisAngleRotation3D.cs
- AdornerHitTestResult.cs
- RightsManagementEncryptionTransform.cs
- WeakReferenceEnumerator.cs
- SqlProfileProvider.cs
- XsltFunctions.cs
- ClonableStack.cs
- RolePrincipal.cs
- FormViewUpdatedEventArgs.cs
- NetNamedPipeSecurityMode.cs
- CodeExpressionStatement.cs
- BehaviorEditorPart.cs
- MethodBuilder.cs
- WebPartDisplayMode.cs
- MulticastIPAddressInformationCollection.cs
- SchemaImporterExtensionElement.cs
- CodeTryCatchFinallyStatement.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- Internal.cs
- CategoryNameCollection.cs
- Predicate.cs
- Int32Rect.cs
- ModuleElement.cs
- Effect.cs
- StoreAnnotationsMap.cs
- Matrix.cs
- ObjectStateFormatter.cs
- WebExceptionStatus.cs
- MeshGeometry3D.cs
- SiteMapDataSource.cs
- HeaderCollection.cs
- AsyncOperationManager.cs
- FragmentQueryProcessor.cs
- ColorMap.cs
- DataListItemEventArgs.cs
- TransportContext.cs
- DataGridViewControlCollection.cs
- MailMessageEventArgs.cs
- HttpListenerPrefixCollection.cs
- ItemsPresenter.cs
- NegationPusher.cs
- Module.cs
- XsltConvert.cs
- PeerInvitationResponse.cs
- DurableRuntimeValidator.cs
- DataGridViewTextBoxCell.cs
- CompositeControl.cs
- ImageIndexConverter.cs
- BaseTemplateParser.cs
- DbReferenceCollection.cs
- JpegBitmapDecoder.cs
- ScrollItemProviderWrapper.cs
- HttpWebRequestElement.cs
- ScriptControlDescriptor.cs
- SymbolEqualComparer.cs
- HttpRuntime.cs
- IDReferencePropertyAttribute.cs
- ProcessHost.cs
- TerminateSequenceResponse.cs
- BrowserTree.cs
- MimeParameters.cs
- UnsafeMethods.cs
- DrawListViewColumnHeaderEventArgs.cs
- ConfigurationStrings.cs
- TrackingProfileCache.cs
- WebPartDisplayMode.cs
- AnchoredBlock.cs
- WebServiceData.cs
- PenThread.cs
- WebPartZone.cs
- AnnotationResourceCollection.cs
- DataGridViewEditingControlShowingEventArgs.cs
- TimelineGroup.cs
- GeneralTransform3DTo2DTo3D.cs
- DoubleLinkListEnumerator.cs
- OleDbDataAdapter.cs
- IncrementalReadDecoders.cs
- SolidBrush.cs
- CommandID.cs
- Char.cs
- PathSegmentCollection.cs
- WriteTimeStream.cs
- NetStream.cs
- DBBindings.cs
- PropertyIDSet.cs
- serverconfig.cs
- filewebresponse.cs
- httpapplicationstate.cs
- BaseResourcesBuildProvider.cs
- DBSchemaTable.cs