Code:
/ 4.0 / 4.0 / 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. // ==++== // // 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
- TextEditor.cs
- FixedPageAutomationPeer.cs
- XPathExpr.cs
- DataPagerField.cs
- SqlAggregateChecker.cs
- DeferredElementTreeState.cs
- AQNBuilder.cs
- ObjectDataSourceFilteringEventArgs.cs
- RoutedEvent.cs
- XmlSchemaNotation.cs
- LinkedList.cs
- ECDsaCng.cs
- SharedPersonalizationStateInfo.cs
- RangeValidator.cs
- GlyphElement.cs
- SmiMetaDataProperty.cs
- NativeMethodsOther.cs
- SamlSecurityToken.cs
- Vector3DAnimationBase.cs
- ArgumentOutOfRangeException.cs
- TableSectionStyle.cs
- MapPathBasedVirtualPathProvider.cs
- ProtocolsConfigurationHandler.cs
- SqlTypeConverter.cs
- GridEntry.cs
- HttpHeaderCollection.cs
- SecurityContext.cs
- TypeBuilderInstantiation.cs
- FilterQuery.cs
- DataGridView.cs
- CodeDirectoryCompiler.cs
- DecimalAverageAggregationOperator.cs
- CodeExpressionStatement.cs
- PageBreakRecord.cs
- BooleanStorage.cs
- ConstraintConverter.cs
- XmlCustomFormatter.cs
- oledbmetadatacolumnnames.cs
- RegexGroupCollection.cs
- PTUtility.cs
- DeflateEmulationStream.cs
- BaseHashHelper.cs
- DataGridTableStyleMappingNameEditor.cs
- CounterCreationData.cs
- XmlnsDefinitionAttribute.cs
- CacheSection.cs
- CompiledRegexRunner.cs
- HyperLink.cs
- Input.cs
- XmlAttributeProperties.cs
- VersionedStreamOwner.cs
- EventItfInfo.cs
- LinkAreaEditor.cs
- HierarchicalDataBoundControl.cs
- GeneralTransform3DTo2DTo3D.cs
- DriveInfo.cs
- CommonRemoteMemoryBlock.cs
- GridItemCollection.cs
- WebPartConnectionsCloseVerb.cs
- XappLauncher.cs
- QfeChecker.cs
- PresentationSource.cs
- brushes.cs
- _SSPISessionCache.cs
- NodeCounter.cs
- DebugView.cs
- ChannelParameterCollection.cs
- PagesSection.cs
- ToolStripItemImageRenderEventArgs.cs
- TextInfo.cs
- EntityDataSourceDataSelectionPanel.cs
- DataGridViewRowPostPaintEventArgs.cs
- InstancePersistenceCommand.cs
- versioninfo.cs
- DataSourceXmlElementAttribute.cs
- RadialGradientBrush.cs
- XMLSyntaxException.cs
- PersonalizableTypeEntry.cs
- RemoteDebugger.cs
- MediaPlayer.cs
- XmlAttributeOverrides.cs
- SynchronizationValidator.cs
- XhtmlBasicControlAdapter.cs
- DataListAutoFormat.cs
- Effect.cs
- List.cs
- DrawingGroup.cs
- SqlTrackingQuery.cs
- ServiceNameCollection.cs
- OdbcConnectionPoolProviderInfo.cs
- SimpleType.cs
- GeneralTransform2DTo3D.cs
- VScrollBar.cs
- BinHexDecoder.cs
- DataControlButton.cs
- DataGridTextBoxColumn.cs
- DateTimeFormatInfo.cs
- DataGridViewDataConnection.cs
- LayoutTableCell.cs
- LayoutTable.cs