[RESOLVED] Creating and using buffers
Hey,
I have never used buffers and have been doing research on them for most of this morning. here is what I currently need to do:
Take the data coming in through the usb and put it into a temporary buffer, after analyzing the data I then have to transfer it to the main buffer.
I have completed everything to do with the analyzing part just need to figure out the buffer part. I am looking at the buffer class -->http://msdn.microsoft.com/en-us/libr...code-snippet-2
But the example doesnt seem to help me. If there is already a buffer within the program how to I create a new one?
EDIT: Did some more research, if someone could verify if my understanding is correct?
Buffer.BlockCopy()
With BlockCopy I am able to specify where the data is coming in and assign the data to an array(Which in this case would be my 'temp buffer')?
I can then analyze the array and copy it to the 'main buffer'?
Re: Creating and using buffers
A buffer is a holder of information. Most often it is just an array of bytes.
The Buffer class, so it seems to me from msdn, is just a class for working with the underlying array. It makes it a little easier versus you handling the array yourself.
So the BlockCopy hasa signature of BlockCopy(Array src,int srcOffset,Array dst,int dstOffset,int count).
The break down:
src is the array you want to copy FROM
srcOffset is where in the source array you want to start coping, EG 5 would indicate you want to start at the 5th element and copy from there on
dst is the array you are copying TO
dstOffset is where you want the destiniation array to start when it copies the elements
count is the number of elements you want to copy
Based on you original statement, yes, you can use this to accomplish what you want
Re: Creating and using buffers
Thanks for the clarification
Just managed to get all the buffer stuff worked out today :)