Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// 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;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TimeSpanParse.cs
- XmlSchemaCollection.cs
- GuidelineSet.cs
- FontInfo.cs
- GridView.cs
- WebPartEditorApplyVerb.cs
- SharedPersonalizationStateInfo.cs
- mediapermission.cs
- ContractListAdapter.cs
- PopupControlService.cs
- XmlSchemaExporter.cs
- SignedXml.cs
- ActiveXHost.cs
- Monitor.cs
- EntityDataSourceEntitySetNameItem.cs
- DelayedRegex.cs
- SqlClientMetaDataCollectionNames.cs
- DefaultValueTypeConverter.cs
- TransactionScope.cs
- BlockCollection.cs
- LocationSectionRecord.cs
- DesignTimeParseData.cs
- Timer.cs
- QilXmlReader.cs
- SerialPinChanges.cs
- DateTimeConstantAttribute.cs
- StringResourceManager.cs
- TemplatedAdorner.cs
- DispatcherEventArgs.cs
- FrameworkElementFactory.cs
- SessionPageStateSection.cs
- CompilerWrapper.cs
- CheckBoxFlatAdapter.cs
- NativeMethods.cs
- XmlTextAttribute.cs
- ClosableStream.cs
- errorpatternmatcher.cs
- TreeViewHitTestInfo.cs
- IncrementalCompileAnalyzer.cs
- DesignerAdRotatorAdapter.cs
- CodeBlockBuilder.cs
- _HTTPDateParse.cs
- IItemContainerGenerator.cs
- TextAction.cs
- XmlSerializableServices.cs
- __Filters.cs
- ExchangeUtilities.cs
- DocobjHost.cs
- KeysConverter.cs
- ZipIOModeEnforcingStream.cs
- CombinedGeometry.cs
- basevalidator.cs
- PropertyTab.cs
- TypographyProperties.cs
- _NegoState.cs
- StyleBamlTreeBuilder.cs
- TransportSecurityBindingElement.cs
- XmlException.cs
- SplitterCancelEvent.cs
- MergeFilterQuery.cs
- PlainXmlSerializer.cs
- PolicyStatement.cs
- BitmapSizeOptions.cs
- SecurityResources.cs
- ContextStaticAttribute.cs
- IsolatedStorageFileStream.cs
- CanExecuteRoutedEventArgs.cs
- QueryPageSettingsEventArgs.cs
- HttpCachePolicyWrapper.cs
- EntityDataSourceColumn.cs
- RTTrackingProfile.cs
- SqlProcedureAttribute.cs
- NgenServicingAttributes.cs
- GACMembershipCondition.cs
- Vertex.cs
- SkewTransform.cs
- CodeCompileUnit.cs
- XmlSchemaAnnotated.cs
- ListViewItemMouseHoverEvent.cs
- QueryContinueDragEventArgs.cs
- CompositeCollection.cs
- TextEvent.cs
- WindowsIdentity.cs
- PageSettings.cs
- BamlLocalizationDictionary.cs
- GeneralTransform.cs
- _DisconnectOverlappedAsyncResult.cs
- StateDesigner.cs
- WindowsStartMenu.cs
- CodeCatchClause.cs
- TriState.cs
- PageAsyncTask.cs
- IBuiltInEvidence.cs
- DbMetaDataCollectionNames.cs
- ContentPropertyAttribute.cs
- RotationValidation.cs
- AppSecurityManager.cs
- WebBrowserBase.cs
- SendActivityDesignerTheme.cs
- LookupBindingPropertiesAttribute.cs