473,748 Members | 7,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4155
On Thu, 24 Apr 2008 08:06:18 -0700, <EF@nospam.nosp amwrote:
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(....,objA rr);

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.nosp amwrote:
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****@microsof t.com.

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

Jun 27 '08 #6

"Alex" <EF@nospam.nosp amwrote in message
news:12******** *************** ***********@mic rosoft.com...
Hi Ben,

Thanks for the suggestion.

What I did to make it work is:

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

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
2761
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 in a querystring, I can't figure out how to convert it back to a CipherMessage.
1
4815
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 to using that color inside color style attribute of some HTML components. Anyone can help me ?
6
15321
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 the another client in C#. Server side can not be changed :( So, I am using tcp/ip sockets. In the end I get byte on the client side, which originally was some C++ class object, converted to byte array.
4
49645
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 row.ToString() But it give result "System.Byte" instead of actual text...
3
3637
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 application, while I am doing for web. I can only find Image from web forms control and HTML control. This may be the root cause of my problem. For read button, I converted his VB to the C#. But the compiler complains:
4
3302
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 errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent the file to wordpad, it shows
1
5414
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 web form to upload a TIFF image (scanned images) and convert it to a JPEG before I insert it into SQL Server. The file upload part works great, but I can;t convert the image. I certainly don't want to upload it the the server filesystem, convert...
9
12687
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
5909
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 vFileHandle is supposed to be a file handle (an IntPtr, I suppose). How can I convert this Byte() in this IntPtr ?
19
5340
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 str(object) does not always attempt to return a string that is acceptable to eval(); its goal is to return a printable string. If no argument is given, returns the empty string, ''.
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4593
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
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 we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.