Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- ApplicationManager.cs
- RegistrationServices.cs
- GeometryCollection.cs
- NonceToken.cs
- ThaiBuddhistCalendar.cs
- UnrecognizedPolicyAssertionElement.cs
- securestring.cs
- AsymmetricKeyExchangeFormatter.cs
- Control.cs
- SystemDropShadowChrome.cs
- ImageBrush.cs
- DocumentViewerAutomationPeer.cs
- SerializationHelper.cs
- DrawingGroupDrawingContext.cs
- ClaimSet.cs
- UniqueIdentifierService.cs
- ImageCodecInfoPrivate.cs
- ResourceReferenceExpression.cs
- AttributeUsageAttribute.cs
- LockCookie.cs
- LineSegment.cs
- XmlReaderSettings.cs
- AppDomainShutdownMonitor.cs
- VariableQuery.cs
- EditingCommands.cs
- XmlNamespaceDeclarationsAttribute.cs
- ProfileBuildProvider.cs
- _ListenerAsyncResult.cs
- FormViewModeEventArgs.cs
- UxThemeWrapper.cs
- Point.cs
- ObjectQuery_EntitySqlExtensions.cs
- BindingCollection.cs
- UpdateProgress.cs
- StringDictionaryWithComparer.cs
- IIS7UserPrincipal.cs
- MetadataPropertyvalue.cs
- EventHandlerList.cs
- DPAPIProtectedConfigurationProvider.cs
- TraceSource.cs
- ScriptingScriptResourceHandlerSection.cs
- EntityKeyElement.cs
- WorkflowApplicationCompletedException.cs
- DescendantOverDescendantQuery.cs
- ConfigurationCollectionAttribute.cs
- PerspectiveCamera.cs
- Environment.cs
- ConfigXmlText.cs
- UpdateTranslator.cs
- SaveFileDialog.cs
- AssemblyBuilder.cs
- CodeCatchClause.cs
- PageStatePersister.cs
- SchemaConstraints.cs
- listitem.cs
- ParameterElementCollection.cs
- XmlImplementation.cs
- XmlHierarchicalDataSourceView.cs
- BulletedList.cs
- SectionUpdates.cs
- MethodExpr.cs
- DockingAttribute.cs
- PrintEvent.cs
- OrderedDictionaryStateHelper.cs
- XmlSerializationWriter.cs
- ObfuscateAssemblyAttribute.cs
- StateItem.cs
- PasswordValidationException.cs
- StringCollection.cs
- WebException.cs
- TreeViewItemAutomationPeer.cs
- ResourceProviderFactory.cs
- TextParagraphProperties.cs
- QilCloneVisitor.cs
- WindowsGraphics2.cs
- BezierSegment.cs
- DeploymentSectionCache.cs
- DataSvcMapFile.cs
- CapacityStreamGeometryContext.cs
- BindingElement.cs
- RegexCharClass.cs
- ThaiBuddhistCalendar.cs
- Stack.cs
- RIPEMD160.cs
- XmlValidatingReaderImpl.cs
- CallbackValidatorAttribute.cs
- GeneralTransform3D.cs
- SafeArrayTypeMismatchException.cs
- XmlSchemaFacet.cs
- Hash.cs
- CollaborationHelperFunctions.cs
- ObjectAnimationBase.cs
- FlowLayoutPanelDesigner.cs
- TriggerAction.cs
- ListBindableAttribute.cs
- StylusButtonCollection.cs
- COM2IProvidePropertyBuilderHandler.cs
- RequiredAttributeAttribute.cs
- UrlPath.cs
- UniqueIdentifierService.cs