I have a byte array buffer that is of a static size.
byte[] buffer = new byte[512];
Data is being read into it using NetworkStream.Read
int countBytes = netStream.Read(buffer, 0, buffer.Length);
For my applicaion, I need to output exactly the number of bytes that were
read in, not the entire buffer. Basically, I need to know how to do
something like this (I know this won't work).
byte[] output = buffer.subString(0, countBytes);
How do I create a new byte array of the correct length?
Thanks in advance,
Will. 4 7661
Will, byte[] output = buffer.subString(0, countBytes);
How do I create a new byte array of the correct length?
byte[] output = new byte[countBytes];
Buffer.BlockCopy(buffer, 0, output, 0, countBytes);
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Hi Will,
See Array,Copy
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com www.rthand.com
"Will" <de*@rusmo.com> wrote in message
news:bd********************@giganews.com... I have a byte array buffer that is of a static size.
byte[] buffer = new byte[512];
Data is being read into it using NetworkStream.Read
int countBytes = netStream.Read(buffer, 0, buffer.Length);
For my applicaion, I need to output exactly the number of bytes that were read in, not the entire buffer. Basically, I need to know how to do something like this (I know this won't work).
byte[] output = buffer.subString(0, countBytes);
How do I create a new byte array of the correct length?
Thanks in advance, Will.
Thanks!
I wasn't aware C# allowed you to instantiate an array with a variable as the
array size.
I'm pretty sure...
int y = 50;
int[] x = new int[y];
....wouldn't compile in C++. I'm pretty sure...
int y = 50; int[] x = new int[y];
...wouldn't compile in C++.
If you correct the syntax it would certainly work
int x[] = new int[y];
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ekim |
last post by:
hello,
I'm allocating a byte-Array in C# with byte byteArray = new byte;
Now I want to pass this byte-Array to a managed C++-function by reference,
so that I'm able to change the content of the...
|
by: Kueishiong Tu |
last post by:
How do I convert a Byte array (unsigned char managed) to a
char array(unmanaged) with wide character taken into
account?
|
by: intrepid_dw |
last post by:
Hello, all.
I've created a C# dll that contains, among other things, two functions
dealing with byte arrays. The first is a function that returns a byte
array, and the other is intended to...
|
by: Dennis |
last post by:
I was trying to determine the fastest way to build a byte array from
components where the size of the individual components varied depending on
the user's input. I tried three classes I built: (1)...
|
by: AmerS |
last post by:
hi, I have been trying to generate image patches for a training set but have not succeded yet. The only method i tried is cropping areas of the image and store the cropped images or patches as an...
|
by: kumari |
last post by:
Hi,
I am facing a problem with generation of thumbnail images in php.
The requirement is as follows: the client would provide the image url,
description, and content through a page.
and the...
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need...
|
by: ThunderMusic |
last post by:
Hi,
The subject says it all... I want to use a byte and use it as byte* so I
can increment the pointer to iterate through it.
What is the fastest way of doing so in C#?
Thanks
ThunderMusic
|
by: Scott Townsend |
last post by:
So I need to talk to a devices that expects all of the bits and bytes I sent
it to be in specific places (not yet 100% defined).
I wanted to create a structure/class with all of the data in it...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |