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
- EventLogPermissionAttribute.cs
- XhtmlBasicPhoneCallAdapter.cs
- SafeRightsManagementHandle.cs
- BinaryFormatter.cs
- WebBrowsableAttribute.cs
- EncoderParameters.cs
- ToolStripGrip.cs
- Select.cs
- PropertyValueUIItem.cs
- Opcode.cs
- PropertyMapper.cs
- GridItemCollection.cs
- FlatButtonAppearance.cs
- FieldAccessException.cs
- ConsoleEntryPoint.cs
- BufferedWebEventProvider.cs
- PeerValidationBehavior.cs
- DashStyle.cs
- EditCommandColumn.cs
- DataStreamFromComStream.cs
- ReflectionPermission.cs
- MetadataItemSerializer.cs
- DataTableCollection.cs
- PeerInputChannel.cs
- PtsContext.cs
- ITreeGenerator.cs
- UnsafeNativeMethods.cs
- DeferredElementTreeState.cs
- InvalidCommandTreeException.cs
- StreamInfo.cs
- HtmlControlPersistable.cs
- WebPartDeleteVerb.cs
- DataGridViewHitTestInfo.cs
- EntityClientCacheEntry.cs
- Signature.cs
- WebBrowserBase.cs
- TransactionBridgeSection.cs
- UnmanagedMemoryStreamWrapper.cs
- CollectionMarkupSerializer.cs
- OracleDateTime.cs
- LineBreakRecord.cs
- MetadataSource.cs
- SqlDataAdapter.cs
- ControlIdConverter.cs
- filewebresponse.cs
- HashMembershipCondition.cs
- StreamWriter.cs
- XmlAttributeAttribute.cs
- ipaddressinformationcollection.cs
- SystemGatewayIPAddressInformation.cs
- IdentityManager.cs
- TextTreeTextElementNode.cs
- Simplifier.cs
- XmlSerializerNamespaces.cs
- AttachedPropertyMethodSelector.cs
- AmbientEnvironment.cs
- SQLRoleProvider.cs
- StorageScalarPropertyMapping.cs
- Math.cs
- ListBoxItemWrapperAutomationPeer.cs
- SiteMapNodeCollection.cs
- ToolStripDropDownClosingEventArgs.cs
- AssociationTypeEmitter.cs
- MetadataSource.cs
- XmlSchemaIdentityConstraint.cs
- DataGridCommandEventArgs.cs
- EntityViewContainer.cs
- GridViewRowCollection.cs
- ProfileService.cs
- ClientRuntimeConfig.cs
- StringStorage.cs
- TextHidden.cs
- XmlSchemaDocumentation.cs
- DefaultCommandConverter.cs
- Stack.cs
- BasePattern.cs
- LinearKeyFrames.cs
- BaseCodePageEncoding.cs
- _NestedSingleAsyncResult.cs
- rsa.cs
- Utilities.cs
- arabicshape.cs
- SemanticBasicElement.cs
- PlaceHolder.cs
- HtmlTextArea.cs
- FixedSOMContainer.cs
- TextServicesDisplayAttribute.cs
- SiteMap.cs
- SafeRightsManagementHandle.cs
- ParseChildrenAsPropertiesAttribute.cs
- XPathNodePointer.cs
- AccessDataSourceView.cs
- ImageListImageEditor.cs
- KeyManager.cs
- SnapshotChangeTrackingStrategy.cs
- UIElement.cs
- EmbeddedMailObject.cs
- DataProtection.cs
- RoleServiceManager.cs
- Char.cs