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
- QilNode.cs
- QuestionEventArgs.cs
- WebPartConnectVerb.cs
- NegotiateStream.cs
- HtmlLink.cs
- XmlExceptionHelper.cs
- FilterElement.cs
- DeviceContext2.cs
- Queue.cs
- TdsParserStaticMethods.cs
- StorageSetMapping.cs
- TextOptionsInternal.cs
- XmlLinkedNode.cs
- CodeEntryPointMethod.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- AssociationEndMember.cs
- XmlSchemaSequence.cs
- FacetValues.cs
- HttpHandlerAction.cs
- XmlAttributeAttribute.cs
- SourceInterpreter.cs
- ExpressionBinding.cs
- CustomErrorsSection.cs
- EditorBrowsableAttribute.cs
- TreeViewItemAutomationPeer.cs
- DirectoryInfo.cs
- SamlConditions.cs
- Propagator.cs
- PropertyChangeTracker.cs
- ZipIOExtraFieldZip64Element.cs
- Size3DValueSerializer.cs
- DoubleKeyFrameCollection.cs
- StreamingContext.cs
- DataErrorValidationRule.cs
- Localizer.cs
- TabRenderer.cs
- ColorContextHelper.cs
- ConfigurationStrings.cs
- DayRenderEvent.cs
- MonitorWrapper.cs
- RegexRunner.cs
- Vector3DIndependentAnimationStorage.cs
- CorrelationTokenTypeConvertor.cs
- NetworkAddressChange.cs
- ArrayList.cs
- ListViewInsertionMark.cs
- ServicePointManager.cs
- FormViewModeEventArgs.cs
- ExecutionScope.cs
- SerializerDescriptor.cs
- DbExpressionVisitor_TResultType.cs
- BindStream.cs
- CalendarDay.cs
- MailWebEventProvider.cs
- TextEditorMouse.cs
- EntityRecordInfo.cs
- SqlCacheDependencyDatabase.cs
- XmlNamespaceMapping.cs
- CacheChildrenQuery.cs
- BinaryFormatterWriter.cs
- StructuralCache.cs
- OdbcInfoMessageEvent.cs
- PassportAuthenticationModule.cs
- HttpCacheVary.cs
- DataRowView.cs
- FixedTextView.cs
- SpecialFolderEnumConverter.cs
- LambdaCompiler.Address.cs
- WebPartMenu.cs
- JournalNavigationScope.cs
- GlyphElement.cs
- SimpleBitVector32.cs
- PersonalizationProviderHelper.cs
- JsonReader.cs
- KeyGesture.cs
- CoordinationService.cs
- FixUpCollection.cs
- TextRangeEdit.cs
- MarshalByRefObject.cs
- DataStreams.cs
- TextShapeableCharacters.cs
- DurableInstance.cs
- StreamingContext.cs
- TextDecorationCollection.cs
- UiaCoreTypesApi.cs
- Parser.cs
- GridViewDeleteEventArgs.cs
- WindowsFormsEditorServiceHelper.cs
- ByteAnimationUsingKeyFrames.cs
- SvcMapFileLoader.cs
- NTAccount.cs
- Rectangle.cs
- SerializationException.cs
- SuppressMergeCheckAttribute.cs
- SafeMILHandleMemoryPressure.cs
- PaintValueEventArgs.cs
- HttpProxyCredentialType.cs
- FlowDocumentScrollViewer.cs
- ScriptControlDescriptor.cs
- ResourcesGenerator.cs