Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- SecurityTokenSerializer.cs
- UrlMappingsModule.cs
- BinaryNode.cs
- XmlNullResolver.cs
- InputBinding.cs
- FilterRepeater.cs
- ThousandthOfEmRealPoints.cs
- TraceListeners.cs
- TemplateControlParser.cs
- ContentType.cs
- TableHeaderCell.cs
- CreateUserWizardDesigner.cs
- DataGridSortCommandEventArgs.cs
- ProxyGenerationError.cs
- GeometryValueSerializer.cs
- MetaData.cs
- BindingMAnagerBase.cs
- SQLString.cs
- TextEndOfParagraph.cs
- RtfToXamlReader.cs
- XmlSchemaFacet.cs
- ISCIIEncoding.cs
- ScriptReferenceEventArgs.cs
- Point.cs
- GeometryValueSerializer.cs
- SmtpReplyReader.cs
- ReferentialConstraint.cs
- WindowsContainer.cs
- Vector3DValueSerializer.cs
- EditorZoneAutoFormat.cs
- webproxy.cs
- DrawingBrush.cs
- WebEventCodes.cs
- EllipseGeometry.cs
- Soap12ProtocolImporter.cs
- SendActivityDesignerTheme.cs
- XamlTypeMapper.cs
- util.cs
- OrderByBuilder.cs
- ToolbarAUtomationPeer.cs
- AutoResetEvent.cs
- ComponentGlyph.cs
- Span.cs
- PropertyFilterAttribute.cs
- IsolatedStorageSecurityState.cs
- ErrorsHelper.cs
- GroupBoxAutomationPeer.cs
- TemplateParser.cs
- DataServiceProviderWrapper.cs
- AttributeUsageAttribute.cs
- PartialToken.cs
- MapPathBasedVirtualPathProvider.cs
- NativeMethods.cs
- ValueConversionAttribute.cs
- EdmToObjectNamespaceMap.cs
- CalendarDateRange.cs
- CustomError.cs
- AuthenticationException.cs
- Byte.cs
- AutomationEventArgs.cs
- EdmProviderManifest.cs
- PeerName.cs
- CharacterString.cs
- InvokeMethod.cs
- NamedElement.cs
- DefaultValueConverter.cs
- StatusBarItem.cs
- AssemblyCacheEntry.cs
- SafeFileMappingHandle.cs
- BackStopAuthenticationModule.cs
- AbstractSvcMapFileLoader.cs
- RoutingTable.cs
- StringDictionary.cs
- ItemList.cs
- XmlNullResolver.cs
- DocumentSequence.cs
- Accessible.cs
- DataGridClipboardCellContent.cs
- StaticExtension.cs
- ThreadStartException.cs
- XmlIgnoreAttribute.cs
- EntityDataSourceWrapper.cs
- SchemaTypeEmitter.cs
- XmlSchemaAll.cs
- X509Extension.cs
- XmlSchemaSimpleTypeRestriction.cs
- MailSettingsSection.cs
- SoapSchemaImporter.cs
- ListControlBuilder.cs
- FocusTracker.cs
- DependencyObjectType.cs
- SoapCodeExporter.cs
- MetaData.cs
- ECDiffieHellmanCngPublicKey.cs
- SynchronizationLockException.cs
- FileSystemEventArgs.cs
- EncoderParameter.cs
- StrongNameUtility.cs
- SafeNativeMethods.cs
- DictionaryEntry.cs