Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / CharEnumerator.cs / 1305376 / 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; using System.Diagnostics.Contracts; [System.Runtime.InteropServices.ComVisible(true)] [Serializable] public sealed class CharEnumerator : IEnumerator, ICloneable, IEnumerator, IDisposable { private String str; private int index; private char currentElement; internal CharEnumerator(String str) { Contract.Requires(str != null); this.str = str; this.index = -1; } [System.Security.SecuritySafeCritical] // auto-generated 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; } public void Dispose() { if (str != null) index = str.Length; str = null; } /// 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
- SqlBuilder.cs
- ImagingCache.cs
- TabOrder.cs
- DelegatingTypeDescriptionProvider.cs
- activationcontext.cs
- CodeMemberEvent.cs
- NameValuePair.cs
- XmlAttributeCache.cs
- ToolStripPanelRenderEventArgs.cs
- ExtentKey.cs
- ApplicationTrust.cs
- PostBackTrigger.cs
- AssociationSetEnd.cs
- XPathBinder.cs
- SHA512.cs
- XmlSchemaValidationException.cs
- OutputScope.cs
- CollectionConverter.cs
- RowToFieldTransformer.cs
- AncillaryOps.cs
- AsymmetricKeyExchangeDeformatter.cs
- XamlBrushSerializer.cs
- OciLobLocator.cs
- RequestResizeEvent.cs
- XmlDataSource.cs
- ToolStripItemBehavior.cs
- DataGridViewRow.cs
- CodeIdentifier.cs
- AnnouncementEndpointElement.cs
- SynchronizedDispatch.cs
- WebPartEditorOkVerb.cs
- CodeMemberProperty.cs
- Formatter.cs
- ToolTipService.cs
- ListDictionary.cs
- translator.cs
- SqlInternalConnection.cs
- DbException.cs
- Pkcs7Signer.cs
- Rotation3DKeyFrameCollection.cs
- TreeBuilder.cs
- ChannelManagerService.cs
- ContentElement.cs
- UIAgentAsyncParams.cs
- ValidationErrorEventArgs.cs
- LinqMaximalSubtreeNominator.cs
- DrawingGroup.cs
- SelectionEditor.cs
- SecurityUtils.cs
- AxisAngleRotation3D.cs
- XmlChoiceIdentifierAttribute.cs
- AnnotationComponentManager.cs
- ImageListUtils.cs
- WSFederationHttpBinding.cs
- ThicknessAnimation.cs
- SmiRequestExecutor.cs
- XNodeNavigator.cs
- GenericPrincipal.cs
- httpapplicationstate.cs
- ProvidersHelper.cs
- TabRenderer.cs
- ImmComposition.cs
- TextTreeInsertElementUndoUnit.cs
- ScaleTransform.cs
- RelatedPropertyManager.cs
- RootBrowserWindow.cs
- WebMessageEncodingElement.cs
- MetaType.cs
- HttpPostProtocolImporter.cs
- DecoderBestFitFallback.cs
- ISAPIApplicationHost.cs
- TextAutomationPeer.cs
- ExtendedPropertyDescriptor.cs
- FreeFormPanel.cs
- autovalidator.cs
- StringConcat.cs
- safemediahandle.cs
- ConfigXmlWhitespace.cs
- BufferBuilder.cs
- SymLanguageType.cs
- Sql8ConformanceChecker.cs
- FlowNode.cs
- BufferBuilder.cs
- ProtocolInformationReader.cs
- DesignerCapabilities.cs
- DropShadowBitmapEffect.cs
- MachineKeyConverter.cs
- UnknownBitmapEncoder.cs
- StylusDownEventArgs.cs
- AssemblyNameUtility.cs
- SocketException.cs
- HttpWebResponse.cs
- UInt16.cs
- CodeComment.cs
- MouseDevice.cs
- SignerInfo.cs
- QueryComponents.cs
- TemporaryBitmapFile.cs
- UnsafeNativeMethods.cs
- TileModeValidation.cs