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
- RequestSecurityTokenResponseCollection.cs
- DatagridviewDisplayedBandsData.cs
- IndexedGlyphRun.cs
- ArcSegment.cs
- Pkcs7Signer.cs
- ToolStripItemImageRenderEventArgs.cs
- GestureRecognizer.cs
- CharKeyFrameCollection.cs
- WebHttpBinding.cs
- XmlDataLoader.cs
- SchemaElement.cs
- MenuItemAutomationPeer.cs
- FileLoadException.cs
- PointConverter.cs
- DependencyPropertyConverter.cs
- JapaneseCalendar.cs
- PropertyGroupDescription.cs
- PolicyValidationException.cs
- SurrogateSelector.cs
- WebPartEditorOkVerb.cs
- FileSystemEnumerable.cs
- ThicknessAnimation.cs
- DataSourceComponent.cs
- DiscardableAttribute.cs
- Bits.cs
- Dynamic.cs
- WSAddressing10ProblemHeaderQNameFault.cs
- WindowsListViewGroup.cs
- FastPropertyAccessor.cs
- XmlHierarchyData.cs
- QuaternionAnimation.cs
- Transform3DGroup.cs
- DataGridViewColumnConverter.cs
- LabelDesigner.cs
- APCustomTypeDescriptor.cs
- BindingNavigator.cs
- SqlRowUpdatingEvent.cs
- SocketElement.cs
- OdbcCommandBuilder.cs
- DesignerCategoryAttribute.cs
- BufferAllocator.cs
- DataGridViewRowCancelEventArgs.cs
- ConfigurationStrings.cs
- GridViewSelectEventArgs.cs
- XmlSchemaAttribute.cs
- XmlAnyAttributeAttribute.cs
- String.cs
- SimpleNameService.cs
- ToolStripPanelRow.cs
- XmlSchemaComplexContent.cs
- ComPersistableTypeElement.cs
- Transform3DGroup.cs
- SchemaAttDef.cs
- HandoffBehavior.cs
- WebContext.cs
- Drawing.cs
- ToolStripLocationCancelEventArgs.cs
- Typeface.cs
- ExpandCollapseProviderWrapper.cs
- StoryFragments.cs
- TimeZone.cs
- XmlDocumentFieldSchema.cs
- httpserverutility.cs
- WindowsAuthenticationEventArgs.cs
- UriParserTemplates.cs
- HttpApplicationStateBase.cs
- ConfigXmlDocument.cs
- SqlInternalConnection.cs
- ImageListStreamer.cs
- ColorAnimationUsingKeyFrames.cs
- BindingSource.cs
- NotEqual.cs
- ToolStripMenuItemCodeDomSerializer.cs
- StringWriter.cs
- MatchAttribute.cs
- OleDbReferenceCollection.cs
- NullableFloatSumAggregationOperator.cs
- MailMessage.cs
- WebChannelFactory.cs
- XmlHierarchicalEnumerable.cs
- WindowsStatusBar.cs
- QualificationDataItem.cs
- ScrollBar.cs
- DataRowCollection.cs
- AuthenticatingEventArgs.cs
- HttpListenerContext.cs
- CharacterBuffer.cs
- TemplateControlCodeDomTreeGenerator.cs
- TextServicesContext.cs
- ProfileGroupSettingsCollection.cs
- XmlBoundElement.cs
- SmtpNetworkElement.cs
- StatusBarAutomationPeer.cs
- ActivityWithResultValueSerializer.cs
- BidOverLoads.cs
- QuadraticBezierSegment.cs
- UpdateTracker.cs
- CounterSample.cs
- ErrorLog.cs
- SqlCharStream.cs