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
- AmbientLight.cs
- BaseResourcesBuildProvider.cs
- LocalIdKeyIdentifierClause.cs
- ScaleTransform.cs
- WindowsFormsHostAutomationPeer.cs
- Camera.cs
- MethodBuilderInstantiation.cs
- Configuration.cs
- LoadMessageLogger.cs
- XmlLanguage.cs
- AdCreatedEventArgs.cs
- WebServiceData.cs
- EmptyStringExpandableObjectConverter.cs
- DesignerForm.cs
- BuildResultCache.cs
- prompt.cs
- Math.cs
- _BasicClient.cs
- RegularExpressionValidator.cs
- BinaryCommonClasses.cs
- WebDisplayNameAttribute.cs
- TypeSource.cs
- _SingleItemRequestCache.cs
- MenuEventArgs.cs
- RSAPKCS1SignatureFormatter.cs
- HttpServerVarsCollection.cs
- SizeValueSerializer.cs
- SqlUserDefinedTypeAttribute.cs
- TextViewBase.cs
- VirtualPathProvider.cs
- SrgsRulesCollection.cs
- VideoDrawing.cs
- ReferencedCategoriesDocument.cs
- Tool.cs
- Compiler.cs
- HelloMessageCD1.cs
- PrimitiveSchema.cs
- DisplayInformation.cs
- UnmanagedMemoryStream.cs
- WindowsAuthenticationModule.cs
- SafeNativeMethods.cs
- SpeechUI.cs
- SelectionListDesigner.cs
- WebBrowserContainer.cs
- XDRSchema.cs
- Invariant.cs
- ServiceHandle.cs
- BitmapEffectGroup.cs
- PersistChildrenAttribute.cs
- ResourceSetExpression.cs
- UrlPath.cs
- ProgressBarAutomationPeer.cs
- CompositeControlDesigner.cs
- ControllableStoryboardAction.cs
- OrderByLifter.cs
- MessageLoggingFilterTraceRecord.cs
- GroupPartitionExpr.cs
- SafeArrayTypeMismatchException.cs
- DataGridViewImageColumn.cs
- XmlDocumentType.cs
- ProcessModelInfo.cs
- ReaderWriterLock.cs
- ImmutableAssemblyCacheEntry.cs
- RectangleGeometry.cs
- CodeDomConfigurationHandler.cs
- MulticastNotSupportedException.cs
- XNodeValidator.cs
- CredentialCache.cs
- WebPartConnectionsCloseVerb.cs
- DataGridViewTextBoxEditingControl.cs
- RootBrowserWindow.cs
- WindowsListViewItemCheckBox.cs
- PersistenceParticipant.cs
- ServiceMetadataBehavior.cs
- ModelVisual3D.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- ImplicitInputBrush.cs
- AuthorizationRule.cs
- DataBoundControlAdapter.cs
- HttpBrowserCapabilitiesWrapper.cs
- DataGridParentRows.cs
- InvokePattern.cs
- KeyProperty.cs
- MissingMemberException.cs
- WebControlsSection.cs
- HostingEnvironmentException.cs
- FileDialogPermission.cs
- WebBrowserContainer.cs
- PrinterUnitConvert.cs
- DataGridViewCellValueEventArgs.cs
- ThreadPool.cs
- _LoggingObject.cs
- WebBodyFormatMessageProperty.cs
- PointAnimation.cs
- CalendarModeChangedEventArgs.cs
- Point3DCollectionValueSerializer.cs
- DrawingDrawingContext.cs
- WebContext.cs
- CodeSubDirectory.cs
- DataGridColumn.cs