Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeDelegateCreateExpression.cs
- COM2EnumConverter.cs
- ObjectDataSourceStatusEventArgs.cs
- TypeReference.cs
- HttpModuleActionCollection.cs
- DbDataReader.cs
- ReliabilityContractAttribute.cs
- RuleElement.cs
- AgileSafeNativeMemoryHandle.cs
- StringAttributeCollection.cs
- HebrewNumber.cs
- ItemCheckEvent.cs
- validation.cs
- OptimalTextSource.cs
- CodeParameterDeclarationExpression.cs
- DynamicControl.cs
- DeploymentExceptionMapper.cs
- RpcCryptoRequest.cs
- DynamicPropertyReader.cs
- TreeNodeMouseHoverEvent.cs
- HttpRequestWrapper.cs
- SqlBuffer.cs
- RootProfilePropertySettingsCollection.cs
- XPathMessageFilterTable.cs
- XPathQilFactory.cs
- SqlTriggerContext.cs
- PropertyKey.cs
- InvokeWebService.cs
- AuthenticationException.cs
- Permission.cs
- ElementHostAutomationPeer.cs
- Directory.cs
- DataRecordInfo.cs
- InvalidWMPVersionException.cs
- DrawingGroup.cs
- PnrpPeerResolverElement.cs
- Comparer.cs
- RubberbandSelector.cs
- ProxyGenerator.cs
- ActivityExecutorOperation.cs
- Resources.Designer.cs
- GeometryHitTestParameters.cs
- SiteMapProvider.cs
- BaseCodePageEncoding.cs
- XmlComplianceUtil.cs
- XmlBaseReader.cs
- StandardCommands.cs
- ShaderEffect.cs
- TrackingStringDictionary.cs
- TileBrush.cs
- PngBitmapEncoder.cs
- TextElementCollectionHelper.cs
- designeractionlistschangedeventargs.cs
- BitmapEffectDrawing.cs
- ObjectStateManager.cs
- FamilyMapCollection.cs
- TypeTypeConverter.cs
- XPathNodeList.cs
- DynamicDataManager.cs
- Material.cs
- Condition.cs
- InputChannelAcceptor.cs
- RenderData.cs
- RegionInfo.cs
- HMACRIPEMD160.cs
- CodeTypeDeclaration.cs
- DataGridViewUtilities.cs
- MsmqDecodeHelper.cs
- WebPartEventArgs.cs
- GenericEnumerator.cs
- ScopelessEnumAttribute.cs
- Debugger.cs
- Table.cs
- MultilineStringConverter.cs
- SignatureDescription.cs
- OrthographicCamera.cs
- ColorConverter.cs
- StyleTypedPropertyAttribute.cs
- LockedBorderGlyph.cs
- OpCellTreeNode.cs
- CellQuery.cs
- WebPartsSection.cs
- TextWriterEngine.cs
- Misc.cs
- ModifierKeysConverter.cs
- LogLogRecordHeader.cs
- WriteableBitmap.cs
- ActivityDesigner.cs
- InteropBitmapSource.cs
- DynamicPropertyReader.cs
- DCSafeHandle.cs
- BaseTemplateBuildProvider.cs
- FontFamilyValueSerializer.cs
- InstanceContextManager.cs
- Attributes.cs
- ServiceSecurityAuditBehavior.cs
- WebPartVerb.cs
- TraceSource.cs
- PasswordBox.cs
- DrawingContextWalker.cs