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 / CharEnumerator.cs / 1 / CharEnumerator.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CharEnumerator ** ** ** Purpose: Enumerates the characters on a string. skips range ** checks. ** ** ============================================================*/ namespace System { using System.Collections; using System.Collections.Generic; [System.Runtime.InteropServices.ComVisible(true)] [Serializable] public sealed class CharEnumerator : IEnumerator, ICloneable, IEnumerator{ private String str; private int index; private char currentElement; internal CharEnumerator(String str) { this.str = str; this.index = -1; } public Object Clone() { return MemberwiseClone(); } public bool MoveNext() { if (index < (str.Length-1)) { index++; currentElement = str[index]; return true; } else index = str.Length; return false; } void IDisposable.Dispose() { } /// Object IEnumerator.Current { get { if (index == -1) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); if (index >= str.Length) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); return currentElement; } } public char Current { get { if (index == -1) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); if (index >= str.Length) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); return currentElement; } } public void Reset() { currentElement = (char)0; index = -1; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CharEnumerator ** ** ** Purpose: Enumerates the characters on a string. skips range ** checks. ** ** ============================================================*/ namespace System { using System.Collections; using System.Collections.Generic; [System.Runtime.InteropServices.ComVisible(true)] [Serializable] public sealed class CharEnumerator : IEnumerator, ICloneable, IEnumerator { private String str; private int index; private char currentElement; internal CharEnumerator(String str) { this.str = str; this.index = -1; } public Object Clone() { return MemberwiseClone(); } public bool MoveNext() { if (index < (str.Length-1)) { index++; currentElement = str[index]; return true; } else index = str.Length; return false; } void IDisposable.Dispose() { } /// Object IEnumerator.Current { get { if (index == -1) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); if (index >= str.Length) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); return currentElement; } } public char Current { get { if (index == -1) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); if (index >= str.Length) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); return currentElement; } } public void Reset() { currentElement = (char)0; index = -1; } } } // 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
- securestring.cs
- XMLSchema.cs
- PingReply.cs
- ValidatingReaderNodeData.cs
- CompositeCollection.cs
- FilterElement.cs
- SynchronizedInputHelper.cs
- ConnectionsZone.cs
- PlacementWorkspace.cs
- Logging.cs
- JoinTreeSlot.cs
- CustomAssemblyResolver.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- DetailsViewUpdateEventArgs.cs
- ToolStripDropDownItem.cs
- ProcessModelInfo.cs
- querybuilder.cs
- BindingExpression.cs
- __TransparentProxy.cs
- RegexTypeEditor.cs
- FontStretches.cs
- HMACSHA512.cs
- BooleanExpr.cs
- ApplicationServicesHostFactory.cs
- WindowsListViewGroupHelper.cs
- Ops.cs
- TypeAccessException.cs
- ISSmlParser.cs
- XmlValueConverter.cs
- HyperlinkAutomationPeer.cs
- WarningException.cs
- SerializationInfoEnumerator.cs
- XPathDescendantIterator.cs
- Panel.cs
- ControlUtil.cs
- TypeDescriptorContext.cs
- AffineTransform3D.cs
- SystemTcpConnection.cs
- WebPartConnectionsConnectVerb.cs
- ItemDragEvent.cs
- RNGCryptoServiceProvider.cs
- DataGridViewColumnEventArgs.cs
- BrowserTree.cs
- MappedMetaModel.cs
- Container.cs
- SelectionProcessor.cs
- Debug.cs
- ChildTable.cs
- TextPenaltyModule.cs
- Preprocessor.cs
- SqlRowUpdatingEvent.cs
- IndexedGlyphRun.cs
- WorkflowApplicationUnloadedException.cs
- DoubleAnimationBase.cs
- NativeMethods.cs
- ResolveMatchesMessage11.cs
- FieldNameLookup.cs
- Int64KeyFrameCollection.cs
- InvalidCommandTreeException.cs
- ByteStack.cs
- ClientType.cs
- CacheVirtualItemsEvent.cs
- Pen.cs
- SemanticBasicElement.cs
- connectionpool.cs
- DataGridColumnHeadersPresenterAutomationPeer.cs
- ClientFormsAuthenticationCredentials.cs
- KeyEventArgs.cs
- BitmapCodecInfoInternal.cs
- CookieHandler.cs
- externdll.cs
- SymbolEqualComparer.cs
- glyphs.cs
- EntityContainerRelationshipSetEnd.cs
- ReferenceSchema.cs
- XmlImplementation.cs
- ProfileModule.cs
- ThicknessAnimationBase.cs
- SessionStateItemCollection.cs
- SQLMoneyStorage.cs
- TextDecorationLocationValidation.cs
- XmlSchemaComplexContentExtension.cs
- UserControl.cs
- ListBindingConverter.cs
- SQLUtility.cs
- AtomContentProperty.cs
- ParameterCollection.cs
- QueueSurrogate.cs
- MenuItemCollection.cs
- DataGridState.cs
- SyndicationSerializer.cs
- StorageSetMapping.cs
- LabelDesigner.cs
- XsdBuildProvider.cs
- TransformPatternIdentifiers.cs
- MdiWindowListStrip.cs
- ToolConsole.cs
- SafeSecurityHandles.cs
- VectorAnimation.cs
- EntityDataSource.cs