Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- AttributeTable.cs
- StackBuilderSink.cs
- NameValueSectionHandler.cs
- MessageQueuePermission.cs
- Timer.cs
- QilReference.cs
- MouseButton.cs
- HttpCookieCollection.cs
- GPPOINT.cs
- AsymmetricCryptoHandle.cs
- Boolean.cs
- Matrix.cs
- FillBehavior.cs
- sqlser.cs
- Opcode.cs
- SecurityRequiresReviewAttribute.cs
- ParameterElementCollection.cs
- HttpChannelFactory.cs
- HttpRequestCacheValidator.cs
- WindowVisualStateTracker.cs
- HyperLinkStyle.cs
- EnlistmentTraceIdentifier.cs
- Assembly.cs
- RenderingEventArgs.cs
- DataException.cs
- TemplatedAdorner.cs
- Tile.cs
- DBSchemaTable.cs
- AdornerDecorator.cs
- ErasingStroke.cs
- BufferModeSettings.cs
- ComponentDispatcherThread.cs
- CorrelationToken.cs
- IncrementalCompileAnalyzer.cs
- WindowsListViewItem.cs
- ProfileBuildProvider.cs
- RefExpr.cs
- ComPlusDiagnosticTraceRecords.cs
- UiaCoreProviderApi.cs
- XmlChildNodes.cs
- MessageLoggingElement.cs
- CopyAction.cs
- PagesSection.cs
- TraceListeners.cs
- ContextMarshalException.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- SkinIDTypeConverter.cs
- IOException.cs
- Vector3D.cs
- CommonDialog.cs
- WindowCollection.cs
- DbConnectionPoolGroupProviderInfo.cs
- EntityStoreSchemaGenerator.cs
- MD5CryptoServiceProvider.cs
- ISAPIRuntime.cs
- XmlResolver.cs
- KeyValuePairs.cs
- XPathNodeHelper.cs
- AppAction.cs
- Int64.cs
- StateInitializationDesigner.cs
- PinnedBufferMemoryStream.cs
- WebSysDefaultValueAttribute.cs
- WebFormDesignerActionService.cs
- ApplicationFileCodeDomTreeGenerator.cs
- WorkflowElementDialogWindow.xaml.cs
- JapaneseLunisolarCalendar.cs
- CodeTypeConstructor.cs
- RIPEMD160.cs
- BuildProvider.cs
- HiddenField.cs
- ProtocolException.cs
- ResumeStoryboard.cs
- ProtocolsConfiguration.cs
- Visual3D.cs
- ElementAction.cs
- StatusBarPanelClickEvent.cs
- IDictionary.cs
- DataGridViewButtonCell.cs
- Delegate.cs
- InvalidPipelineStoreException.cs
- PkcsUtils.cs
- Splitter.cs
- AssemblyUtil.cs
- StoreItemCollection.cs
- ColumnCollection.cs
- AddressingVersion.cs
- WmpBitmapDecoder.cs
- ObjectDataSourceStatusEventArgs.cs
- FontSource.cs
- Identity.cs
- FacetChecker.cs
- AssemblyCollection.cs
- LocalIdKeyIdentifierClause.cs
- Table.cs
- DbCommandDefinition.cs
- Line.cs
- QuaternionValueSerializer.cs
- CompatibleComparer.cs
- Rect.cs