473,503 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

redef array

Mex
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
Jun 12 '07 #1
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};
Jun 12 '07 #2
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
Jun 12 '07 #3
Mex
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};


Jun 12 '07 #4

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

Similar topics

2
2757
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); }
2
575
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...
15
5155
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>
8
3463
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(...
12
55526
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...
8
10198
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...
58
10046
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...
35
6591
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>
11
39428
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...
0
7202
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
7084
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...
0
7278
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,...
1
5013
isladogs
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...
0
4672
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...
0
3167
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...
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
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...

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.