Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / ComponentModel / ArraySubsetEnumerator.cs / 1 / 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
- CompiledQuery.cs
- StringValueConverter.cs
- CookieProtection.cs
- FileSystemInfo.cs
- XmlCodeExporter.cs
- IpcChannel.cs
- SqlServer2KCompatibilityCheck.cs
- BamlBinaryReader.cs
- HyperLinkDesigner.cs
- BreakRecordTable.cs
- ElementHostPropertyMap.cs
- NonSerializedAttribute.cs
- SqlVisitor.cs
- FontSourceCollection.cs
- ConstantCheck.cs
- AbandonedMutexException.cs
- DoubleKeyFrameCollection.cs
- NaturalLanguageHyphenator.cs
- MemberAccessException.cs
- UnsafeNativeMethods.cs
- BooleanKeyFrameCollection.cs
- LongTypeConverter.cs
- InternalEnumValidatorAttribute.cs
- ViewGenResults.cs
- SettingsSavedEventArgs.cs
- ResourceSet.cs
- FixedSOMSemanticBox.cs
- GenericEnumerator.cs
- Set.cs
- QueryContinueDragEventArgs.cs
- CAGDesigner.cs
- DependencyObject.cs
- IPGlobalProperties.cs
- CompositeFontInfo.cs
- ToolStripTemplateNode.cs
- StickyNoteHelper.cs
- SingleStorage.cs
- SafeNativeMethods.cs
- InstalledFontCollection.cs
- OutputCacheEntry.cs
- DetailsViewUpdatedEventArgs.cs
- ProgressBarAutomationPeer.cs
- HtmlInputHidden.cs
- User.cs
- RotateTransform3D.cs
- ConfigurationPropertyAttribute.cs
- CngProperty.cs
- DataErrorValidationRule.cs
- SamlAudienceRestrictionCondition.cs
- ObjectDataProvider.cs
- StrokeNodeEnumerator.cs
- LZCodec.cs
- OpacityConverter.cs
- SelectionRange.cs
- CustomAttributeFormatException.cs
- CompilationRelaxations.cs
- RegexNode.cs
- GenericEnumerator.cs
- ContractHandle.cs
- ConfigurationLocationCollection.cs
- CacheMemory.cs
- EventLogPropertySelector.cs
- FieldInfo.cs
- WebPart.cs
- TextBox.cs
- TransactionBridge.cs
- CompilerWrapper.cs
- HtmlButton.cs
- figurelengthconverter.cs
- MarkupCompilePass2.cs
- OracleDataReader.cs
- COM2PropertyDescriptor.cs
- BaseValidatorDesigner.cs
- TraceHandlerErrorFormatter.cs
- Bitmap.cs
- WinOEToolBoxItem.cs
- CaretElement.cs
- DecimalAnimationBase.cs
- HierarchicalDataBoundControlAdapter.cs
- FormatException.cs
- BufferBuilder.cs
- ToolStripContainer.cs
- TransformerTypeCollection.cs
- WindowsTreeView.cs
- PeerMessageDispatcher.cs
- ZipIOExtraFieldElement.cs
- GridViewSortEventArgs.cs
- ExtendedPropertyCollection.cs
- TitleStyle.cs
- FixedSOMTableCell.cs
- DefaultBinder.cs
- RemotingClientProxy.cs
- Compilation.cs
- EventSinkHelperWriter.cs
- TemplateControl.cs
- QilTargetType.cs
- SessionParameter.cs
- PreviewPrintController.cs
- MsmqIntegrationChannelFactory.cs
- HttpException.cs