Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / ComponentModel / ArraySubsetEnumerator.cs / 1305376 / ArraySubsetEnumerator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel { using System; using System.Collections; using System.Diagnostics; using System.Security.Permissions; [HostProtection(SharedState = true)] internal class ArraySubsetEnumerator : IEnumerator { private Array array; private int total; private int current; public ArraySubsetEnumerator(Array array, int count) { Debug.Assert(count == 0 || array != null, "if array is null, count should be 0"); Debug.Assert(array == null || count <= array.Length, "Trying to enumerate more than the array contains"); this.array = array; this.total = count; current = -1; } public bool MoveNext() { if (current < total - 1) { current++; return true; } else { return false; } } public void Reset() { current = -1; } public object Current { get { if (current == -1) { throw new InvalidOperationException(); } else { return array.GetValue(current); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel { using System; using System.Collections; using System.Diagnostics; using System.Security.Permissions; [HostProtection(SharedState = true)] internal class ArraySubsetEnumerator : IEnumerator { private Array array; private int total; private int current; public ArraySubsetEnumerator(Array array, int count) { Debug.Assert(count == 0 || array != null, "if array is null, count should be 0"); Debug.Assert(array == null || count <= array.Length, "Trying to enumerate more than the array contains"); this.array = array; this.total = count; current = -1; } public bool MoveNext() { if (current < total - 1) { current++; return true; } else { return false; } } public void Reset() { current = -1; } public object Current { get { if (current == -1) { throw new InvalidOperationException(); } else { return array.GetValue(current); } } } } } // 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
- Convert.cs
- Document.cs
- StructuredTypeInfo.cs
- BamlMapTable.cs
- keycontainerpermission.cs
- Int64Converter.cs
- ListenerUnsafeNativeMethods.cs
- CacheDependency.cs
- SpnEndpointIdentity.cs
- ProgressBarRenderer.cs
- CaseStatement.cs
- OleDbPermission.cs
- XmlQualifiedName.cs
- CodeAttributeArgument.cs
- CodeTypeReferenceExpression.cs
- TransactionValidationBehavior.cs
- GenericEnumerator.cs
- EventBookmark.cs
- ResourceDictionary.cs
- XmlSiteMapProvider.cs
- InputProcessorProfilesLoader.cs
- EventLogPermissionAttribute.cs
- SettingsAttributes.cs
- SpeakCompletedEventArgs.cs
- OrderPreservingPipeliningMergeHelper.cs
- WinFormsSecurity.cs
- UnsafeNativeMethods.cs
- SocketPermission.cs
- TaiwanLunisolarCalendar.cs
- Color.cs
- ImageInfo.cs
- EventLogPermissionEntryCollection.cs
- LookupTables.cs
- TreeView.cs
- ViewCellSlot.cs
- StrokeNodeData.cs
- Keyboard.cs
- PeerObject.cs
- SafeFileHandle.cs
- ProxyWebPart.cs
- DataGridViewAddColumnDialog.cs
- InheritablePropertyChangeInfo.cs
- XmlSchemaExporter.cs
- FrameworkObject.cs
- UIElementIsland.cs
- HostedElements.cs
- DocumentScope.cs
- EventSinkHelperWriter.cs
- ItemChangedEventArgs.cs
- DynamicResourceExtensionConverter.cs
- CommonGetThemePartSize.cs
- AnnotationAdorner.cs
- ResXFileRef.cs
- JapaneseLunisolarCalendar.cs
- EventLogInternal.cs
- KeyPullup.cs
- FormatConvertedBitmap.cs
- DataGridViewRowCollection.cs
- Assert.cs
- DoubleLink.cs
- InkCanvasFeedbackAdorner.cs
- TCPListener.cs
- ProcessManager.cs
- SQLMoneyStorage.cs
- DecryptedHeader.cs
- SmiGettersStream.cs
- Table.cs
- SqlTypeSystemProvider.cs
- ContractBase.cs
- LogicalMethodInfo.cs
- DataGridLengthConverter.cs
- SoapAttributeOverrides.cs
- OrderedDictionary.cs
- ToolboxBitmapAttribute.cs
- ConnectionInterfaceCollection.cs
- XmlTextReaderImplHelpers.cs
- XmlIgnoreAttribute.cs
- RenameRuleObjectDialog.Designer.cs
- MexTcpBindingCollectionElement.cs
- XMLDiffLoader.cs
- HandlerMappingMemo.cs
- WebScriptClientGenerator.cs
- SBCSCodePageEncoding.cs
- PageRanges.cs
- OperatingSystem.cs
- __Filters.cs
- WebPartDisplayModeCollection.cs
- DocumentPageView.cs
- VisualStyleRenderer.cs
- AsymmetricKeyExchangeFormatter.cs
- BatchParser.cs
- ObfuscationAttribute.cs
- SqlXmlStorage.cs
- SspiSafeHandles.cs
- ResetableIterator.cs
- ServiceObjectContainer.cs
- SqlParameterCollection.cs
- ListenerElementsCollection.cs
- Table.cs
- CodeAttributeDeclaration.cs