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
- SortDescriptionCollection.cs
- RegistrySecurity.cs
- TagNameToTypeMapper.cs
- Simplifier.cs
- SortedList.cs
- PingOptions.cs
- util.cs
- BamlReader.cs
- SimpleTableProvider.cs
- TaskFormBase.cs
- HyperLinkDesigner.cs
- hresults.cs
- AutomationPeer.cs
- NegotiateStream.cs
- METAHEADER.cs
- RepeaterItemCollection.cs
- ReferentialConstraint.cs
- ActivityDesignerAccessibleObject.cs
- AuthenticationException.cs
- LinqToSqlWrapper.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- XPathAncestorIterator.cs
- NumericUpDownAccelerationCollection.cs
- String.cs
- SerializerWriterEventHandlers.cs
- XmlFileEditor.cs
- Matrix3DConverter.cs
- CompatibleIComparer.cs
- ToolStripDropDown.cs
- ToolStripSplitStackLayout.cs
- DiscoveryExceptionDictionary.cs
- InheritanceUI.cs
- SqlTypesSchemaImporter.cs
- mactripleDES.cs
- EntitySetBase.cs
- JsonReaderWriterFactory.cs
- SqlExpander.cs
- SqlDataRecord.cs
- SmtpNegotiateAuthenticationModule.cs
- RefExpr.cs
- SafeMarshalContext.cs
- DataView.cs
- StandardCommandToolStripMenuItem.cs
- RegexRunnerFactory.cs
- CompiledIdentityConstraint.cs
- DefaultConfirmation.cs
- DateBoldEvent.cs
- RijndaelCryptoServiceProvider.cs
- FacetChecker.cs
- EventlogProvider.cs
- SqlBuilder.cs
- FrameworkReadOnlyPropertyMetadata.cs
- BitmapEncoder.cs
- FlowLayoutSettings.cs
- Descriptor.cs
- ListViewGroupCollectionEditor.cs
- SizeValueSerializer.cs
- CounterSampleCalculator.cs
- EventMappingSettingsCollection.cs
- UnmanagedMemoryStream.cs
- WorkflowDebuggerSteppingAttribute.cs
- WrappedReader.cs
- ExpandoObject.cs
- DocumentSequenceHighlightLayer.cs
- ConfigUtil.cs
- ReadOnlyHierarchicalDataSource.cs
- securitycriticaldataClass.cs
- SQLDecimal.cs
- ResourceDisplayNameAttribute.cs
- VectorCollectionValueSerializer.cs
- ApplicationGesture.cs
- Double.cs
- InternalsVisibleToAttribute.cs
- StyleReferenceConverter.cs
- PreProcessor.cs
- XmlElementCollection.cs
- SoapObjectInfo.cs
- ButtonBaseAdapter.cs
- OrCondition.cs
- UIElementAutomationPeer.cs
- HttpCapabilitiesEvaluator.cs
- ThemeDirectoryCompiler.cs
- GeometryModel3D.cs
- DbInsertCommandTree.cs
- RequestChannelBinder.cs
- ProxyAttribute.cs
- EnumerableRowCollection.cs
- ProfileParameter.cs
- UIElement.cs
- NameValueSectionHandler.cs
- AsymmetricAlgorithm.cs
- HttpContext.cs
- errorpatternmatcher.cs
- EntryPointNotFoundException.cs
- DataGridItemCollection.cs
- AxHostDesigner.cs
- GPPOINT.cs
- FileDialogCustomPlace.cs
- ToolStripLocationCancelEventArgs.cs
- OptimizerPatterns.cs