Code:
/ DotNET / DotNET / 8.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
- ProcessModuleCollection.cs
- FormatVersion.cs
- UserPersonalizationStateInfo.cs
- DragEventArgs.cs
- AccessDataSource.cs
- HttpHandlersSection.cs
- _LoggingObject.cs
- Collection.cs
- ConfigurationStrings.cs
- HandleCollector.cs
- SerializationSectionGroup.cs
- SqlBulkCopy.cs
- PropertyEmitterBase.cs
- ChangePassword.cs
- LicenseException.cs
- Rfc2898DeriveBytes.cs
- MobileListItemCollection.cs
- Journal.cs
- ToolboxComponentsCreatingEventArgs.cs
- Image.cs
- DelegatingConfigHost.cs
- ApplicationHost.cs
- UserMapPath.cs
- FontDriver.cs
- embossbitmapeffect.cs
- HttpCachePolicyElement.cs
- CommandEventArgs.cs
- Message.cs
- PaginationProgressEventArgs.cs
- PreDigestedSignedInfo.cs
- SchemaExporter.cs
- FixedLineResult.cs
- ApplicationContext.cs
- TripleDESCryptoServiceProvider.cs
- XmlNodeChangedEventArgs.cs
- AttributeCollection.cs
- SqlDataSourceFilteringEventArgs.cs
- OutputCacheSection.cs
- EdmSchemaAttribute.cs
- TextTreeTextNode.cs
- WebPartConnection.cs
- MdImport.cs
- PeerApplicationLaunchInfo.cs
- VerificationAttribute.cs
- SqlClientWrapperSmiStream.cs
- ViewSimplifier.cs
- ReadOnlyDataSource.cs
- Color.cs
- ActiveXHelper.cs
- PenThreadWorker.cs
- AddDataControlFieldDialog.cs
- UntypedNullExpression.cs
- PropertyInfoSet.cs
- ReflectionUtil.cs
- ProtocolsConfigurationEntry.cs
- WpfWebRequestHelper.cs
- HtmlEmptyTagControlBuilder.cs
- BevelBitmapEffect.cs
- TypographyProperties.cs
- WebZone.cs
- ClientUtils.cs
- GridViewRowCollection.cs
- ValueProviderWrapper.cs
- SecurityTokenRequirement.cs
- TypedElement.cs
- SecondaryViewProvider.cs
- NamespaceQuery.cs
- CompilerInfo.cs
- Msmq4SubqueuePoisonHandler.cs
- NativeMethods.cs
- dsa.cs
- QuaternionRotation3D.cs
- EdmItemCollection.OcAssemblyCache.cs
- UnmanagedMemoryStreamWrapper.cs
- EdmItemCollection.cs
- StretchValidation.cs
- XmlSchemaAnnotation.cs
- TableColumn.cs
- MemberInitExpression.cs
- DataTableReader.cs
- StorageComplexPropertyMapping.cs
- HTMLTextWriter.cs
- InputScopeAttribute.cs
- MimeImporter.cs
- DeviceContext2.cs
- XmlCodeExporter.cs
- uribuilder.cs
- LayoutInformation.cs
- EmptyStringExpandableObjectConverter.cs
- Unit.cs
- XhtmlTextWriter.cs
- XmlQueryStaticData.cs
- CommandBindingCollection.cs
- RunInstallerAttribute.cs
- KeyTime.cs
- SamlAdvice.cs
- AuthenticationException.cs
- GifBitmapEncoder.cs
- DataSourceCache.cs
- XmlSchemaRedefine.cs