473,236 Members | 1,307 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,236 software developers and data experts.

how to convert byte[] to object[]

Hi,

How do I convert a byte[] to an object[]?

I am trying to use IADs PutEx and the last parameter required a variant
array.

Thanks,
Alex
Jun 27 '08 #1
6 4103
On Thu, 24 Apr 2008 08:06:18 -0700, <EF@nospam.nospamwrote:
How do I convert a byte[] to an object[]?
Copy each element to an object[]. I take as granted that you really have
to do this, 'cause it's not going to be efficient. :)

Pete
Jun 27 '08 #2
EF@nospam.nospam wrote:
Hi,

How do I convert a byte[] to an object[]?

I am trying to use IADs PutEx and the last parameter required a
variant array.
I suspect what you need is:

byte[] barray;
PutEx(..., new object[] { barray });
>
Thanks,
Alex

Jun 27 '08 #3
Hi Ben,

Thanks for the suggestion.

What I did to make it work is:

object[] objArr = new object[1];
objArr[0] = barray;
PutEx(....,objArr);

As I am just learning C# so I am not so familar with your syntax. Is it
doing the same?

Thanks,
Alex
"Ben Voigt [C++ MVP]" wrote:
EF@nospam.nospam wrote:
Hi,

How do I convert a byte[] to an object[]?

I am trying to use IADs PutEx and the last parameter required a
variant array.

I suspect what you need is:

byte[] barray;
PutEx(..., new object[] { barray });

Thanks,
Alex


Jun 27 '08 #4
Hi Peter,

I did manage to convert byte[] to object[] using Arrays.Copy but it does not
solve me problem. Actually PutEx is expecting an object array containing
byte array. Doing that so my problem.

Thanks,
Alex

"Peter Duniho" wrote:
On Thu, 24 Apr 2008 08:06:18 -0700, <EF@nospam.nospamwrote:
How do I convert a byte[] to an object[]?

Copy each element to an object[]. I take as granted that you really have
to do this, 'cause it's not going to be efficient. :)

Pete
Jun 27 '08 #5
Hi Alex,

Thanks for your feedback.

Actually your code works the same way as what Ben provided. "new object[] {
barray }" means creating an object array with length determined by the
number of elements in {}. Since there is only one element "barray" in the
{}, the object array will have length "one". Also, in this one element
object array, the only element is a reference to the byte array. This is
the same logic as your code does

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '08 #6

"Alex" <EF@nospam.nospamwrote in message
news:12**********************************@microsof t.com...
Hi Ben,

Thanks for the suggestion.

What I did to make it work is:

object[] objArr = new object[1];
objArr[0] = barray;
PutEx(....,objArr);

As I am just learning C# so I am not so familar with your syntax. Is it
doing the same?
Yes, the compiler will expand

new T[] { t1, t2, ... tn }

into

T[] temp = new T[n];
temp[0] = t1;
temp[1] = t2;
temp[n-1] = tn;

and use temp in the original function call

>
Thanks,
Alex
"Ben Voigt [C++ MVP]" wrote:
>EF@nospam.nospam wrote:
Hi,

How do I convert a byte[] to an object[]?

I am trying to use IADs PutEx and the last parameter required a
variant array.

I suspect what you need is:

byte[] barray;
PutEx(..., new object[] { barray });
>
Thanks,
Alex


Jun 27 '08 #7

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

Similar topics

2
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
1
by: Lamberti Fabrizio | last post by:
Hi all. I've got an ActiveX Object that gives me OleColor codes for its graphical components. I need to convert these OleColor codes into RGB codes using JScript or VBScript, becuase I have...
6
by: Gator | last post by:
Hi All, Basically my situation is this, I have a server implemented in C++, unmanaged code, using proprietery protocol over TCP/IP to communicate with the cilent(c++ also). Now, I am implementing...
4
by: Serge Klokov | last post by:
Hello! I have a Oracle table with a BLOB field. Each field is actually a simple text file of several lines. How to get this BLOB fields in readable format? I tryied something like...
3
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
9
by: Charles Law | last post by:
Suppose I have a structure Private Structure MyStruct Dim el1 As Byte Dim el2 As Int16 Dim el3 As Byte End Structure I want to convert this into a byte array where
8
by: Serge BRIC | last post by:
My application, written in .NET VB, tries to get a communication port handle from a TAPI object with this code: Dim vFileHandle As Byte() = appel.GetIDAsVariant("comm/datamodem") The...
19
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
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...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
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 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.