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
- Axis.cs
- HtmlInputControl.cs
- TransactionOptions.cs
- TrustLevel.cs
- DataGridViewMethods.cs
- AutomationEvent.cs
- IndentedWriter.cs
- Scheduling.cs
- SocketException.cs
- Validator.cs
- GridViewColumnHeader.cs
- CoreSwitches.cs
- uribuilder.cs
- UIElement3DAutomationPeer.cs
- StringReader.cs
- FacetEnabledSchemaElement.cs
- OleDbDataReader.cs
- AppearanceEditorPart.cs
- NativeCompoundFileAPIs.cs
- Quad.cs
- ItemCollection.cs
- TraceHandlerErrorFormatter.cs
- AQNBuilder.cs
- CustomAssemblyResolver.cs
- SqlError.cs
- ExpressionPrefixAttribute.cs
- ExtensionFile.cs
- HtmlElementEventArgs.cs
- QueryOperator.cs
- XmlSignatureManifest.cs
- SymbolEqualComparer.cs
- OleDbEnumerator.cs
- Function.cs
- ErrorWrapper.cs
- SqlCacheDependencySection.cs
- FunctionDetailsReader.cs
- AutoGeneratedField.cs
- DeploymentExceptionMapper.cs
- _PooledStream.cs
- PageAsyncTask.cs
- XmlHierarchicalDataSourceView.cs
- OleAutBinder.cs
- TagNameToTypeMapper.cs
- ParseHttpDate.cs
- SafeRightsManagementSessionHandle.cs
- StringKeyFrameCollection.cs
- ImageSourceConverter.cs
- ValidationResult.cs
- RegexRunnerFactory.cs
- TreeNodeConverter.cs
- BindingGroup.cs
- StringUtil.cs
- PngBitmapDecoder.cs
- XmlSchemaValidator.cs
- MemberHolder.cs
- DiscoveryClientReferences.cs
- SourceSwitch.cs
- LocationEnvironment.cs
- DataControlFieldCell.cs
- VideoDrawing.cs
- X509SecurityToken.cs
- _FtpDataStream.cs
- HttpStreamXmlDictionaryWriter.cs
- HierarchicalDataBoundControl.cs
- ProfileService.cs
- Models.cs
- StandardOleMarshalObject.cs
- SR.cs
- CursorConverter.cs
- FutureFactory.cs
- LoginUtil.cs
- SerializationTrace.cs
- MenuItem.cs
- InputBindingCollection.cs
- CheckBoxFlatAdapter.cs
- CipherData.cs
- RoutedUICommand.cs
- AnnotationResource.cs
- CellConstantDomain.cs
- FileUtil.cs
- ManipulationStartingEventArgs.cs
- DetailsView.cs
- GetBrowserTokenRequest.cs
- ChtmlTextBoxAdapter.cs
- HtmlImage.cs
- XPathScanner.cs
- DataSet.cs
- DecoderExceptionFallback.cs
- WebPartEditorApplyVerb.cs
- LockCookie.cs
- WinFormsUtils.cs
- HMAC.cs
- HttpPostedFile.cs
- MethodRental.cs
- TraceEventCache.cs
- DetailsView.cs
- PinnedBufferMemoryStream.cs
- OracleRowUpdatedEventArgs.cs
- ConnectionStringSettings.cs
- _Events.cs