473,396 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

copying a subsection of an array to another array?

I have two byte arrays, X and Y. X contains 100 elements, and Y has 10
elements. I want Y to equal X[50] through X[59]. How can I do this without
a loop? While in this example the arrays are only maxing at 100, in reality
there will be up to 5MB+ stored in this byte array, hence the lack of
wanting to use a loop to do this convertion.

I have seen many builtin convert-to methods take in 3 params: byte[], int
first index, int last index. Then it would convert that subsection to, for
example, a string. Well, I was hoping for a similar method, but for a
byte[] to byte[] convertion, but can not seem to find one. Can someone
point me to the proper method that can do this? Or, is my only option a
hideous loop?

Thanks
-jeric
Nov 15 '05 #1
1 2623
Array.Copy(ArraytoCopyFrom, IndexFromSource, DestinationArray,
IndexForDestination,
LengthToCopy)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"jeric" <us**@mypc.test> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
I have two byte arrays, X and Y. X contains 100 elements, and Y has 10
elements. I want Y to equal X[50] through X[59]. How can I do this without a loop? While in this example the arrays are only maxing at 100, in reality there will be up to 5MB+ stored in this byte array, hence the lack of
wanting to use a loop to do this convertion.

I have seen many builtin convert-to methods take in 3 params: byte[], int
first index, int last index. Then it would convert that subsection to, for example, a string. Well, I was hoping for a similar method, but for a
byte[] to byte[] convertion, but can not seem to find one. Can someone
point me to the proper method that can do this? Or, is my only option a
hideous loop?

Thanks
-jeric

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
2
by: Don | last post by:
Using JS, how do I copy an associative array from one frame to another? Here's what I tried, and didn't work. In "main" frame referencing "header" frame: var cookies = new Object(); cookies...
5
by: Roy Hills | last post by:
When I'm reading from or writing to a network socket, I want to use a struct to represent the structured data, but must use an unsigned char buffer for the call to sendto() or recvfrom(). I have...
4
by: Lafer | last post by:
Hello, I am attempting to write a terminal interface program using PowerPC Assembly/C, where I am using an integer-to-ASCII conversion algorithm. Unfortunately, I have run into some difficulties...
1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
3
by: Derrick | last post by:
If I have an array.. object myObjs = someMethod.SearchForObjs(); and the length of that array is 100, but I want to extract the last 80 objects into another array, what's the cleanest way to...
2
by: Soumyadip Rakshit | last post by:
I have a 2D Array of Integers A. I would like to copy it to another array B taking each row at a time. They are both initialized as pointers to pointers. I would like to use something like the...
6
by: Jeff Brooks | last post by:
I need to copy a record one access record into the same table. I just need to modify a couple fields that the user will change. Im sure there is an easy way to do it. I have started just reading...
1
by: RonLandreth | last post by:
I am writing an accounting system for a class I'm taking at SLU. I need help figuring out the best way to go about copying a 2D array to a temporary 2D array, for eventually copying it back. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.