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
- CompModHelpers.cs
- querybuilder.cs
- TypeHelpers.cs
- BinaryWriter.cs
- SHA256Managed.cs
- PipelineComponent.cs
- RoutedPropertyChangedEventArgs.cs
- HexParser.cs
- FixedTextSelectionProcessor.cs
- DesignerProperties.cs
- CallSite.cs
- BulletedList.cs
- CollectionViewProxy.cs
- TextFormatterImp.cs
- XmlSerializationReader.cs
- MDIControlStrip.cs
- TrackingQueryElement.cs
- NameSpaceEvent.cs
- WinInet.cs
- DataTemplateKey.cs
- MouseWheelEventArgs.cs
- MgmtResManager.cs
- SizeChangedInfo.cs
- HttpDictionary.cs
- XmlWrappingReader.cs
- ThreadStateException.cs
- FactoryGenerator.cs
- RegexCompilationInfo.cs
- ScriptManager.cs
- ImageMetadata.cs
- EditingScope.cs
- FlatButtonAppearance.cs
- FormatterServices.cs
- TextDecorationUnitValidation.cs
- MappingModelBuildProvider.cs
- securitycriticaldata.cs
- Invariant.cs
- BitmapDownload.cs
- MemberPath.cs
- Parser.cs
- BeginEvent.cs
- GenericAuthenticationEventArgs.cs
- EventLogPermissionEntryCollection.cs
- InputLanguageCollection.cs
- SmiConnection.cs
- StyleCollectionEditor.cs
- JoinSymbol.cs
- oledbmetadatacolumnnames.cs
- EventLogger.cs
- MinimizableAttributeTypeConverter.cs
- ParentUndoUnit.cs
- ISessionStateStore.cs
- AutomationEventArgs.cs
- SortedList.cs
- Queue.cs
- TransformerInfoCollection.cs
- HuffModule.cs
- AdornerPresentationContext.cs
- PingReply.cs
- CommandField.cs
- TcpHostedTransportConfiguration.cs
- BufferBuilder.cs
- DataGridItemCollection.cs
- Pen.cs
- FormsAuthenticationEventArgs.cs
- IconBitmapDecoder.cs
- XmlSchema.cs
- namescope.cs
- RequestQueryProcessor.cs
- JpegBitmapEncoder.cs
- StyleTypedPropertyAttribute.cs
- ApplyTemplatesAction.cs
- CompatibleIComparer.cs
- ClientConfigurationSystem.cs
- RenderCapability.cs
- SizeChangedEventArgs.cs
- SqlMethods.cs
- sqlstateclientmanager.cs
- Variable.cs
- Int32CollectionConverter.cs
- RemoteWebConfigurationHost.cs
- UserPreferenceChangingEventArgs.cs
- ArithmeticException.cs
- ADMembershipUser.cs
- AccessDataSourceView.cs
- NamespaceEmitter.cs
- ActiveXHelper.cs
- DataGridViewColumn.cs
- RegularExpressionValidator.cs
- NumericPagerField.cs
- ContextProperty.cs
- GenericTextProperties.cs
- ScrollItemPatternIdentifiers.cs
- ListViewItemMouseHoverEvent.cs
- WebPartTransformerCollection.cs
- DataTemplateKey.cs
- MetadataUtil.cs
- HMACSHA384.cs
- InputLanguageSource.cs
- DataSourceCache.cs