473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to initialize Byte^ array?

Cat
Hi.
static readonly byte[] Exponent = new byte[] {0x1, 0x0, 0x1 };
This is a C# code. I would like to do the same thing in Managed C++
static array<Byte^>^ Exponent = gcnew array<Byte^>(3) {0x1, 0x0,
0x1 };
But this caused,
error C2440: 'initializing' : cannot convert from 'int' to
'System::Byte ^'
How can I fix this? Please give me a hint.
Thank you.
Feb 5 '08 #1
2 15823
Cat
On Feb 6, 2:02*am, Cat <typing...@gmail.comwrote:
Hi.
* *static readonly byte[] Exponent = new byte[] {0x1, 0x0, 0x1 };
This is a C# code. I would like to do the same thing in Managed C++
* *static array<Byte^>^ Exponent = gcnew array<Byte^>(3) {0x1, 0x0,
0x1 };
But this caused,
* error C2440: 'initializing' : cannot convert from 'int' to
'System::Byte ^'
How can I fix this? Please give me a hint.
Thank you.
Is it impossible to initialize Byte^ at declaration in MC++?
Feb 5 '08 #2

"Cat" <ty*******@gmail.comwrote in message
news:a2**********************************@n20g2000 hsh.googlegroups.com...
Hi.
static readonly byte[] Exponent = new byte[] {0x1, 0x0, 0x1 };
This is a C# code. I would like to do the same thing in Managed C++
static array<Byte^>^ Exponent = gcnew array<Byte^>(3) {0x1, 0x0,
0x1 };
But this caused,
error C2440: 'initializing' : cannot convert from 'int' to
'System::Byte ^'

The error message says it all - you can't initialize Byte references with
integers.

It looks like you meant to allocate an array of Bytes, not an array of
Byte^s...

array<Byte>^ Exponent = gcnew array<Byte>(3){0x1, 0x0, 0x1};

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

How can I fix this? Please give me a hint.
Thank you.
Feb 5 '08 #3

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

Similar topics

6
by: Kai Wu | last post by:
#include <string.h> #include <fstream> #include <time.h> typedef unsigned char BYTE; struct Dex { BYTE status; struct timeval timestamp; }; int main(){
4
by: Mark Hannon | last post by:
I am trying to initialize an array only once so it can be seen & used by any functions that need it. As I understand it, if a variable is declared by itself outside of any functions, its scope is...
1
by: MAF | last post by:
Is there a quick way to initialize an array with one value for example int IDs = new int; I want all items to be initialized to -1.
8
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...
3
by: Russell Mangel | last post by:
Hi, I would like to encapsulate the following CRC32 routine inside a C++ un-mananged class. I am having difficulty initializing the "const static unsigned int table" inside an un-managed C++...
6
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)...
1
by: Kevin | last post by:
Hi I am specifying a byte array of known size using Dim data(100) As Byte which creates an array with 0's. I would like to create the array with a specific value instead of zeros, if my...
17
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...
24
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.