Hi
How to redfine(resize) byte array in the same scope?
lets say
byte[] pbSendBuffer= {0x0,0xA4,0x0,0xC};
//do something
now i want use same variable but
pbSendBuffer={0x0,0xa4,0x1,0xc,0x2,0xee,0xee};
Is it possible?
Best regards;
Mex 3 3722
"Mex" <re*******@hot.eewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
How to redfine(resize) byte array in the same scope?
lets say
byte[] pbSendBuffer= {0x0,0xA4,0x0,0xC};
//do something
now i want use same variable but
pbSendBuffer={0x0,0xa4,0x1,0xc,0x2,0xee,0xee};
Is it possible?
Not directly. The size of the arrays is immutable, so you have to
destroy and recreate the array. You can replace your last line with this
one:
pbSendBuffer = new byte[]{0x0,0xa4,0x1,0xc,0x2,0xee,0xee};
Mex <re*******@hot.eewrote:
How to redfine(resize) byte array in the same scope?
lets say
byte[] pbSendBuffer= {0x0,0xA4,0x0,0xC};
//do something
now i want use same variable but
pbSendBuffer={0x0,0xa4,0x1,0xc,0x2,0xee,0xee};
Is it possible?
You need to create a new array, eg
pbSendBuffer = new byte[] {0x0,0xa4,0x1,0xc,0x2,0xee,0xee};
If you want to create a new array which has the contents of another
array to start with, look at Array.Resize<T(if you're using C# 2).
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
ehh of course :)))
thnx!
Mex
"Alberto Poblacion" <ea******************************@poblacion.orgwro te
in message news:%2****************@TK2MSFTNGP02.phx.gbl...
"Mex" <re*******@hot.eewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>How to redfine(resize) byte array in the same scope?
lets say
byte[] pbSendBuffer= {0x0,0xA4,0x0,0xC};
//do something
now i want use same variable but
pbSendBuffer={0x0,0xa4,0x1,0xc,0x2,0xee,0xee};
Is it possible?
Not directly. The size of the arrays is immutable, so you have to
destroy and recreate the array. You can replace your last line with this
one:
pbSendBuffer = new byte[]{0x0,0xa4,0x1,0xc,0x2,0xee,0xee};
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brian |
last post by:
I'm diddlying with a script, and found some behavior I don't understand.
Take this snippet:
for ($i = 0; $i <= count($m); $i++) {
array_shift($m);
reset($m);
}
|
by: Stormkid |
last post by:
Hi Group I'm trying to figure out a way that I can take two (two
dimensional) arrays and avShed and shed, and subtract the matching elements
in shed from avShed I've pasted the arrays blow from a...
|
by: lawrence |
last post by:
I wanted to test xml_parse_into_struct() so I took the example off of
www.php.net and put this code up on a site:
<?php
$simple = <<<END
<item>
|
by: vcardillo |
last post by:
Hello all,
Okay, I am having some troubles. What I am doing here is dealing with
an employee hierarchy that is stored in an array. It looks like this:
$employees = array( "user_id" => array(...
|
by: Sam Collett |
last post by:
How do I remove an item with a specified value from an array?
i.e. array values 1,2,2,5,7,12,15,21
remove 2 from array would return
1,5,7,12,15,21
(12 and 21 are NOT removed, duplicates are...
| |
by: Mike S. Nowostawsky |
last post by:
I tried using the "toUpperCase()" property to change the value of an array
entity to uppercase BUT it tells me that the property is invalid. It seems
that an array is not considered an object when...
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of...
|
by: VK |
last post by:
Whatever you wanted to know about it but always were affraid to ask.
<http://www.geocities.com/schools_ring/ArrayAndHash.html>
|
by: deko |
last post by:
I need to create a basic one-dimensional array of strings, but I don't know
how many strings I'm going to have until the code is finished looping.
pseudo code:
Dim astrMyArray()
Do While Not...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |