Hello,
I have the following code:
background:
const int MAX_DATA_BYTES=250;
byte[] blkin =new byte[MAX_DATA_BYTES]; /* Receive buffer */
and I use it in the following:
memmove(blkout[1], blkout[0], len);
but i get the following error:
Cannot apply indexing with [] to an expression of type 'byte'
What am i doing wrong?
Thanks
mike 12 1623
Actually I changed memmove to ARRAY.COPY. (Sorry, Im porting a c
program to c#)
AMP wrote:
Hello,
I have the following code:
background:
const int MAX_DATA_BYTES=250;
byte[] blkin =new byte[MAX_DATA_BYTES]; /* Receive buffer */
and I use it in the following:
memmove(blkout[1], blkout[0], len);
but i get the following error:
Cannot apply indexing with [] to an expression of type 'byte'
What am i doing wrong?
Thanks
mike
Let me rewrite this:
Hello,
I have the following code:
background:
const int MAX_DATA_BYTES=250;
byte[] blkout =new byte[MAX_DATA_BYTES]; /* Receive buffer */
and I use it in the following:
ARRAY.COPY(blkout[1], blkout[0], len);
but i get the following error:
Cannot apply indexing with [] to an expression of type 'byte'
Mike,
You are showing the declaration for the blkin variable, but your call on
the indexer is for the blkout variable. I would take a look at that.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"AMP" <am******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,
I have the following code:
background:
const int MAX_DATA_BYTES=250;
byte[] blkin =new byte[MAX_DATA_BYTES]; /* Receive buffer */
and I use it in the following:
memmove(blkout[1], blkout[0], len);
but i get the following error:
Cannot apply indexing with [] to an expression of type 'byte'
What am i doing wrong?
Thanks
mike
Take a look at the Buffer.BlockCopy method for this.
Willy.
"AMP" <am******@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
| Let me rewrite this:
| Hello,
| I have the following code:
| background:
| const int MAX_DATA_BYTES=250;
| byte[] blkout =new byte[MAX_DATA_BYTES]; /* Receive buffer */
|
| and I use it in the following:
| ARRAY.COPY(blkout[1], blkout[0], len);
|
| but i get the following error:
| Cannot apply indexing with [] to an expression of type 'byte'
|
Still not getting anywhere.
I need some help.Please
Thanks
Mike
Willy Denoyette [MVP] wrote:
Take a look at the Buffer.BlockCopy method for this.
Willy.
"AMP" <am******@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
| Let me rewrite this:
| Hello,
| I have the following code:
| background:
| const int MAX_DATA_BYTES=250;
| byte[] blkout =new byte[MAX_DATA_BYTES]; /* Receive buffer */
|
| and I use it in the following:
| ARRAY.COPY(blkout[1], blkout[0], len);
|
| but i get the following error:
| Cannot apply indexing with [] to an expression of type 'byte'
|
"AMP" <am******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
| Still not getting anywhere.
| I need some help.Please
| Thanks
| Mike
|
What problem do you have using BlockCopy? Please post what you have done so
far.
Here's a usage sample:
byte[] arr1 = {1, 2, 3, 4, 5};
byte[] arr2 = {10, 11, 12, 13, 14, 15};
// copy 5 bytes from arr1 starting at offset 0 to arr2 starting at offset 1
Buffer.BlockCopy( arr1, 0, arr2, 1, 5);
// result: arr2 = 10, 1, 2, 3, 4, 5
Willy.
At 18:14:54, 10.09.2006, AMP wrote:
Let me rewrite this:
Hello,
I have the following code:
background:
const int MAX_DATA_BYTES=250;
byte[] blkout =new byte[MAX_DATA_BYTES]; /* Receive buffer */
and I use it in the following:
ARRAY.COPY(blkout[1], blkout[0], len);
Array.Copy has a different parameter set. Assuming the original C code
was:
memmove(blkout + 1, blkout, len);
or:
memmove(&blkout[1], &blkout[0], len);
then try this:
Array.Copy(blkout, 0, blkout, 1, len);
Where blkout[0] is the source and blkout[1] is the destination.
--
Rudy Velthuis http://rvelthuis.de/
"If you're sick and tired of the politics of cynicism and polls
and principles, come and join this campaign." -- George W. Bush
Yes the original code was:
memmove(&blkout[1], &blkout[0], len);
so why doesnt my code work????????????
const int MAX_DATA_BYTES=250;
byte[] blkout=new byte[MAX_DATA_BYTES]; /* Transmit buffer */
Array.Copy(blkout,1, blkout,0, len);
what i'm getting now is:
Error 10 Argument '1': cannot convert from 'byte' to
'System.Array' M:\Rocket-CSharp\Rocket\Rocket\Form1.cs 466 20 Rocket
And
Error 11 Argument '3': cannot convert from 'byte' to
'System.Array' M:\Rocket-CSharp\Rocket\Rocket\Form1.cs 466 30 Rocket
And the next line in the program is:
blkout[0]= 0xFF;
and i get the error:
Error 12 Cannot apply indexing with [] to an expression of type
'byte' M:\Rocket-CSharp\Rocket\Rocket\Form1.cs 467 9 Rocket
I dont get it.............
Thanks Again
Mike
Rudy Velthuis wrote:
At 18:14:54, 10.09.2006, AMP wrote:
Let me rewrite this:
Hello,
I have the following code:
background:
const int MAX_DATA_BYTES=250;
byte[] blkout =new byte[MAX_DATA_BYTES]; /* Receive buffer */
and I use it in the following:
ARRAY.COPY(blkout[1], blkout[0], len);
Array.Copy has a different parameter set. Assuming the original C code
was:
memmove(blkout + 1, blkout, len);
or:
memmove(&blkout[1], &blkout[0], len);
then try this:
Array.Copy(blkout, 0, blkout, 1, len);
Where blkout[0] is the source and blkout[1] is the destination.
--
Rudy Velthuis http://rvelthuis.de/
"If you're sick and tired of the politics of cynicism and polls
and principles, come and join this campaign." -- George W. Bush
AMP <am******@gmail.comwrote:
Yes the original code was:
memmove(&blkout[1], &blkout[0], len);
so why doesnt my code work????????????
const int MAX_DATA_BYTES=250;
byte[] blkout=new byte[MAX_DATA_BYTES]; /* Transmit buffer */
Array.Copy(blkout,1, blkout,0, len);
The above code compiles fine. The problem was when you were using
blkout[1] or blkout[0], which each evaluate to a byte value, not a byte
array.
--
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
I managed to fix that one,(Many Thanks) but I have one that looks like
this:
memcpy(&dataOut[4], blkout, len)
The "blkout" has no index.
Any Suggestions?
Jon wrote:
AMP <am******@gmail.comwrote:
Yes the original code was:
memmove(&blkout[1], &blkout[0], len);
so why doesnt my code work????????????
const int MAX_DATA_BYTES=250;
byte[] blkout=new byte[MAX_DATA_BYTES]; /* Transmit buffer */
Array.Copy(blkout,1, blkout,0, len);
The above code compiles fine. The problem was when you were using
blkout[1] or blkout[0], which each evaluate to a byte value, not a byte
array.
--
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
AMP wrote:
I managed to fix that one,(Many Thanks) but I have one that looks like
this:
memcpy(&dataOut[4], blkout, len)
The "blkout" has no index.
Any Suggestions?
That's basically
Array.Copy (dataOut, 4, blkout, 0, len);
(or possibly the other way round - I can't remember which way round the
arguments go in memcpy).
Jon
Jon Skeet [C# MVP] wrote:
AMP wrote:
>I managed to fix that one,(Many Thanks) but I have one that looks like this: memcpy(&dataOut[4], blkout, len)
The "blkout" has no index. Any Suggestions?
That's basically
Array.Copy (dataOut, 4, blkout, 0, len);
(or possibly the other way round - I can't remember which way round the
arguments go in memcpy).
memcpy is <- !
Arne This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Trevor Fairchild |
last post by:
I've got a program that parses text files. The text files come to me
in Unicode and they contain goofy characters that VB chokes on -
treats them as eof markers. I have already been through this...
|
by: Michael Gaab |
last post by:
How would I force the compiler to throw an error for the following:
function signature -
void foo(short);
function call -
foo('d');
My compiler does not complain when I call foo() with a...
|
by: Glen |
last post by:
I'm working on a custom assembly and I'm trying to figure out the best
approach to handling known constraints within the assembly, once
compiled, to alert the developer at compile time of a...
|
by: Jimski |
last post by:
Hello all,
I am having a problem where I get an error message when I call
FlushFinalBlock when decrypting my encrypted text. I am using the
Rijndael algorithm.
The error message is "Length...
|
by: wxs |
last post by:
Many times we have a bunch of enums we have from either different enums or
the same enum that will have various numeric values assigned. Rarely will
there be collisions in numbering between the...
|
by: Sharon |
last post by:
I'm trying to convert an Image file to a byte array .
Later in my code I'm trying to create a new Image from this byte array as
a restored Image.
But when I try to save the restored Image to a...
|
by: Ken |
last post by:
When running a program in the debugger, what would cause it to crash without
any error messages? I get "The program has exited with code 0 (0x0)".
The program is a MDI app with threading for...
|
by: Ismail Fatih Yıldırım |
last post by:
I modified the RSACSPSample from MSDN to try out a simple commutative
encryption model using RSA encryption but when i run the progrem the first
encryption command works but during the second...
|
by: wong_powah |
last post by:
#include <vector>
#include <iostream>
using std::cout;
using std::vector;
enum {DATASIZE = 20};
typedef unsigned char data_t;
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
| |