Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / clr / src / BCL / System / ArraySegment.cs / 1 / ArraySegment.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: ArraySegment** ** ** Purpose: Convenient wrapper for an array, an offset, and ** a count. Ideally used in streams & collections. ** Net Classes will consume an array of these. ** ** ===========================================================*/ using System.Runtime.InteropServices; namespace System { [Serializable] public struct ArraySegment { private T[] _array; private int _offset; private int _count; public ArraySegment(T[] array) { if (array == null) throw new ArgumentNullException("array"); _array = array; _offset = 0; _count = array.Length; } public ArraySegment(T[] array, int offset, int count) { if (array == null) throw new ArgumentNullException("array"); if (offset < 0) throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if (count < 0) throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if (array.Length - offset < count) throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); _array = array; _offset = offset; _count = count; } public T[] Array { get { return _array; } } public int Offset { get { return _offset; } } public int Count { get { return _count; } } public override int GetHashCode() { return _array.GetHashCode() ^ _offset ^ _count; } public override bool Equals(Object obj) { if (obj is ArraySegment ) return Equals((ArraySegment )obj); else return false; } public bool Equals(ArraySegment obj) { return obj._array == _array && obj._offset == _offset && obj._count == _count; } public static bool operator ==(ArraySegment a, ArraySegment b) { return a.Equals(b); } public static bool operator !=(ArraySegment a, ArraySegment b) { return !(a == b); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: ArraySegment ** ** ** Purpose: Convenient wrapper for an array, an offset, and ** a count. Ideally used in streams & collections. ** Net Classes will consume an array of these. ** ** ===========================================================*/ using System.Runtime.InteropServices; namespace System { [Serializable] public struct ArraySegment { private T[] _array; private int _offset; private int _count; public ArraySegment(T[] array) { if (array == null) throw new ArgumentNullException("array"); _array = array; _offset = 0; _count = array.Length; } public ArraySegment(T[] array, int offset, int count) { if (array == null) throw new ArgumentNullException("array"); if (offset < 0) throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if (count < 0) throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if (array.Length - offset < count) throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); _array = array; _offset = offset; _count = count; } public T[] Array { get { return _array; } } public int Offset { get { return _offset; } } public int Count { get { return _count; } } public override int GetHashCode() { return _array.GetHashCode() ^ _offset ^ _count; } public override bool Equals(Object obj) { if (obj is ArraySegment ) return Equals((ArraySegment )obj); else return false; } public bool Equals(ArraySegment obj) { return obj._array == _array && obj._offset == _offset && obj._count == _count; } public static bool operator ==(ArraySegment a, ArraySegment b) { return a.Equals(b); } public static bool operator !=(ArraySegment a, ArraySegment b) { return !(a == b); } } } // 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
- CompositeDataBoundControl.cs
- ByteAnimationUsingKeyFrames.cs
- DataContract.cs
- UTF7Encoding.cs
- X509CertificateTrustedIssuerElement.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- UInt16Storage.cs
- CodeObjectCreateExpression.cs
- QuaternionIndependentAnimationStorage.cs
- ValueProviderWrapper.cs
- FixUpCollection.cs
- XhtmlConformanceSection.cs
- UserControlBuildProvider.cs
- JapaneseCalendar.cs
- DataMemberConverter.cs
- unsafenativemethodsother.cs
- CommandID.cs
- TextViewBase.cs
- TransformDescriptor.cs
- InputScope.cs
- EnumerationRangeValidationUtil.cs
- VirtualPathProvider.cs
- ChildrenQuery.cs
- SrgsGrammarCompiler.cs
- RemotingException.cs
- HelpInfo.cs
- StrongNameKeyPair.cs
- URI.cs
- SchemaTypeEmitter.cs
- ProgressBar.cs
- WmlControlAdapter.cs
- FatalException.cs
- SlotInfo.cs
- Property.cs
- CompilerInfo.cs
- AccessDataSource.cs
- ToolBarButton.cs
- CrossAppDomainChannel.cs
- CollectionBase.cs
- StringAnimationBase.cs
- HtmlUtf8RawTextWriter.cs
- TrustManager.cs
- FileAuthorizationModule.cs
- Substitution.cs
- DelayLoadType.cs
- ResizeGrip.cs
- loginstatus.cs
- SynchronizationScope.cs
- SqlConnectionStringBuilder.cs
- ExtensionFile.cs
- RegularExpressionValidator.cs
- DtdParser.cs
- httpserverutility.cs
- WebReferencesBuildProvider.cs
- RegionInfo.cs
- ValidationSummary.cs
- ShutDownListener.cs
- DisplayMemberTemplateSelector.cs
- TreeNodeCollection.cs
- GlobalProxySelection.cs
- UpdateRecord.cs
- FlowDocumentPaginator.cs
- ManifestResourceInfo.cs
- DataGridViewCellFormattingEventArgs.cs
- HebrewNumber.cs
- WebProxyScriptElement.cs
- WebPartsSection.cs
- WorkflowMarkupSerializationException.cs
- OuterGlowBitmapEffect.cs
- initElementDictionary.cs
- DataTrigger.cs
- PeerNameResolver.cs
- ComboBoxRenderer.cs
- DoubleAnimation.cs
- PieceNameHelper.cs
- PrePostDescendentsWalker.cs
- OletxCommittableTransaction.cs
- SelectionManager.cs
- PathFigureCollectionConverter.cs
- SrgsElementFactoryCompiler.cs
- XPathNodeInfoAtom.cs
- XmlObjectSerializerContext.cs
- ReferentialConstraint.cs
- OleDbParameterCollection.cs
- AuthorizationRuleCollection.cs
- AsymmetricKeyExchangeDeformatter.cs
- AspNetHostingPermission.cs
- SortDescription.cs
- DbParameterCollectionHelper.cs
- SmtpSection.cs
- ContractCodeDomInfo.cs
- SafeLocalMemHandle.cs
- EastAsianLunisolarCalendar.cs
- SchemaElement.cs
- TextUtf8RawTextWriter.cs
- ToolStripPanelCell.cs
- TreeView.cs
- DocumentSchemaValidator.cs
- IPEndPoint.cs
- LogEntryDeserializer.cs