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
- SamlAction.cs
- NumberAction.cs
- CodeTypeDelegate.cs
- MemberInfoSerializationHolder.cs
- SecurityElement.cs
- Utilities.cs
- RepeatInfo.cs
- ReadOnlyCollectionBase.cs
- Catch.cs
- Missing.cs
- PrintDialog.cs
- SecurityDocument.cs
- DiffuseMaterial.cs
- XmlElementAttributes.cs
- Object.cs
- ExceptionValidationRule.cs
- SQLInt64Storage.cs
- SymLanguageType.cs
- StatusBarAutomationPeer.cs
- WeakReferenceList.cs
- Style.cs
- ExtractedStateEntry.cs
- FixedFlowMap.cs
- OdbcParameter.cs
- AdapterUtil.cs
- ETagAttribute.cs
- EnumBuilder.cs
- ContentType.cs
- AccessorTable.cs
- ValidationSummary.cs
- NonVisualControlAttribute.cs
- GrammarBuilderBase.cs
- Content.cs
- DependencyPropertyKey.cs
- FactoryGenerator.cs
- ReachSerializer.cs
- ConditionCollection.cs
- StronglyTypedResourceBuilder.cs
- PointIndependentAnimationStorage.cs
- ObjectAnimationUsingKeyFrames.cs
- _UriTypeConverter.cs
- SecureEnvironment.cs
- ToolStripManager.cs
- Char.cs
- PerformanceCounterScope.cs
- CurrentChangingEventArgs.cs
- DataBinding.cs
- BitmapEffect.cs
- FilterableAttribute.cs
- DbMetaDataColumnNames.cs
- X509Extension.cs
- SafeCryptHandles.cs
- Win32MouseDevice.cs
- AppDomain.cs
- PrintPageEvent.cs
- Executor.cs
- EnumValidator.cs
- DataGridViewCellLinkedList.cs
- BamlWriter.cs
- PlanCompiler.cs
- SqlGatherProducedAliases.cs
- BitmapFrameEncode.cs
- MultiTrigger.cs
- Listbox.cs
- SymmetricSecurityProtocol.cs
- SR.cs
- _FtpControlStream.cs
- JavaScriptObjectDeserializer.cs
- XmlRawWriter.cs
- IxmlLineInfo.cs
- WebServiceHostFactory.cs
- FrameworkContentElementAutomationPeer.cs
- UnitControl.cs
- ListItemCollection.cs
- WebExceptionStatus.cs
- UnsafeNativeMethods.cs
- ServiceDescriptions.cs
- GradientBrush.cs
- AudioSignalProblemOccurredEventArgs.cs
- WaitHandleCannotBeOpenedException.cs
- GraphicsState.cs
- EventWaitHandle.cs
- OleDbFactory.cs
- FieldNameLookup.cs
- BitmapEffectGeneralTransform.cs
- WebEvents.cs
- DataGridViewCellParsingEventArgs.cs
- HostExecutionContextManager.cs
- Overlapped.cs
- ToolStripContentPanelRenderEventArgs.cs
- DataServiceQueryException.cs
- GridViewDeletedEventArgs.cs
- Focus.cs
- StackBuilderSink.cs
- CryptoApi.cs
- URLAttribute.cs
- DataRow.cs
- UriWriter.cs
- Pen.cs
- TableLayoutStyle.cs