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
- CacheDependency.cs
- DictionaryEditChange.cs
- SortKey.cs
- WindowsRichEdit.cs
- FixedSOMTextRun.cs
- Timer.cs
- EmbeddedMailObjectsCollection.cs
- DataGridCell.cs
- lengthconverter.cs
- ServiceNotStartedException.cs
- RNGCryptoServiceProvider.cs
- FontWeight.cs
- ScalarConstant.cs
- Sql8ConformanceChecker.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- IdentityHolder.cs
- Size3D.cs
- InputLanguage.cs
- BitmapEffectDrawingContextState.cs
- ReferenceAssemblyAttribute.cs
- CompositeFontParser.cs
- ShaperBuffers.cs
- securestring.cs
- ImmutablePropertyDescriptorGridEntry.cs
- PanningMessageFilter.cs
- CompilerGeneratedAttribute.cs
- GridLength.cs
- TextOnlyOutput.cs
- OdbcException.cs
- SmiXetterAccessMap.cs
- VoiceObjectToken.cs
- ServiceCredentialsElement.cs
- CheckBox.cs
- ResourcesGenerator.cs
- InstanceDataCollection.cs
- PEFileEvidenceFactory.cs
- FixedSOMSemanticBox.cs
- EntityDataSourceValidationException.cs
- Char.cs
- SafeNativeMethods.cs
- PreApplicationStartMethodAttribute.cs
- SmtpException.cs
- NotCondition.cs
- TrustManagerPromptUI.cs
- NavigationWindow.cs
- AssociationTypeEmitter.cs
- ExtentJoinTreeNode.cs
- BitmapSizeOptions.cs
- InkCanvasSelectionAdorner.cs
- SkipStoryboardToFill.cs
- EnterpriseServicesHelper.cs
- GroupPartitionExpr.cs
- Simplifier.cs
- ValidationRuleCollection.cs
- DocumentXPathNavigator.cs
- ControlValuePropertyAttribute.cs
- PackageFilter.cs
- AuthenticationModulesSection.cs
- DeclarativeConditionsCollection.cs
- OutputCacheProfileCollection.cs
- SystemUdpStatistics.cs
- PeerInvitationResponse.cs
- KeyGestureValueSerializer.cs
- SecureUICommand.cs
- XmlDataCollection.cs
- BindingExpressionBase.cs
- FixedSOMPageConstructor.cs
- FontStyle.cs
- ReadOnlyCollectionBase.cs
- PeerObject.cs
- ISessionStateStore.cs
- XmlSerializerFaultFormatter.cs
- ReadOnlyObservableCollection.cs
- MessageQueue.cs
- RenderingEventArgs.cs
- PersonalizationDictionary.cs
- ControlBindingsCollection.cs
- AddDataControlFieldDialog.cs
- BasePattern.cs
- XmlSchema.cs
- COM2AboutBoxPropertyDescriptor.cs
- TextTreeDeleteContentUndoUnit.cs
- XslVisitor.cs
- EntityExpressionVisitor.cs
- AjaxFrameworkAssemblyAttribute.cs
- SQLBoolean.cs
- HttpApplicationStateBase.cs
- ClientRequest.cs
- NegotiationTokenAuthenticatorStateCache.cs
- Win32Native.cs
- URLAttribute.cs
- SizeLimitedCache.cs
- SqlComparer.cs
- SQlBooleanStorage.cs
- DataGridHeaderBorder.cs
- AssemblyResourceLoader.cs
- DSASignatureFormatter.cs
- ByeMessageApril2005.cs
- Int32RectValueSerializer.cs
- EntityType.cs