I need some help converting byte[] into Array:
int bufferLen = Convert.ToInt32(file.Length);
byte buffer = new byte[bufferLen];
int len = sr.Read(buffer, 0, bufferLen);
ArrayList a = new ArrayList(len);
a.Add(buffer);
Array result = a.toArray();
Something like that... 6 17231
Peter,
An Array class is not the same thing as an ArrayList. When you add an
item to ArrayList, you can only access it by accessing its index. So I
believe you are looking for something like this:
byte[] byteArray = new byte[1];
byteArray[0] = 1;
ArrayList arrayList = new ArrayList(byteArray.Length);
arrayList.Add(byteArray);
byte[] someByteArray = (byte[]) arrayList[0];
Best Regards
Johann Blake
> So I believe you are looking for something like this:
No. :(
I need Array class, because I'm using it in COM automation (SafeArray).
Something like this:
int bufferLen = Convert.ToInt32(file.Length);
char[] buffer = new char[bufferLen];
int len = sr.Read(buffer, 0, bufferLen);
byte[] tmp = new byte[0]; //Need VT_UI1 automation type. Is this OK?
Array a = Array.CreateInstance(tmp.GetType(), len);
a.SetValue(buffer);
Does this work for you?
byte[] ba = new byte[2];
Array ar = (Array)ba;
--
William Stacey [MVP]
"Petar Popara" <my*****@mail.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... So I believe you are looking for something like this:
No. :(
I need Array class, because I'm using it in COM automation (SafeArray).
Something like this:
int bufferLen = Convert.ToInt32(file.Length); char[] buffer = new char[bufferLen]; int len = sr.Read(buffer, 0, bufferLen); byte[] tmp = new byte[0]; //Need VT_UI1 automation type. Is this OK? Array a = Array.CreateInstance(tmp.GetType(), len); a.SetValue(buffer); Does this work for you?
Yes. :)
I'm beginner with C# and even trivial things confuses me.
Is "byte" same as "unsigned char" (BYTE) in C/C++? I need VT_UI1 automation
(compatible) type.
> Is "byte" same as "unsigned char" (BYTE) in C/C++? I need VT_UI1
automation (compatible) type.
yes.
Hi,
What you want to do ?
your code should work changing these lines like
byte buffer = new byte[bufferLen];
a.Add(buffer);
for
byte[] buffer = new byte[bufferLen];
a.AddRange( buffer )
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Petar Popara" <my*****@mail.net> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl... I need some help converting byte[] into Array:
int bufferLen = Convert.ToInt32(file.Length); byte buffer = new byte[bufferLen]; int len = sr.Read(buffer, 0, bufferLen); ArrayList a = new ArrayList(len); a.Add(buffer);
Array result = a.toArray();
Something like that... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jeff |
last post by:
how do you convert form byte to Int32 while retaining the binary
value of the byte array
|
by: Swarup |
last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling
it into a byte arry. Now i have to convert it into a string to store it in
the database.
I use...
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the "byte array" into a string.
the problem is that...
|
by: MuZZy |
last post by:
Hi,
I just wonder if someone can help me wit this -
i have a byte array and need to convert it to short array, creating
short numbers by combining bytes by pairs:
My array: byte, byte, byte,...
|
by: Kueishiong Tu |
last post by:
How do I convert a Byte array (unsigned char managed) to a
char array(unmanaged) with wide character taken into
account?
|
by: moondaddy |
last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a
string, and then from a string back to a byte array.
for example
Private mByte() as New Byte(4){11,22,33,44}
Now how...
|
by: Peter |
last post by:
Trying to convert string to byte array.
the following code returns byte array of {107, 62, 194, 139, 64}
how can I convert this string to a byte array of {107, 62, 139, 65}
...
|
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...
|
by: da1978 |
last post by:
Hi experts,
I need to convert a string or a Byte array to a string byte array.
Its relatively easy to convert a string to an char array or a byte array but not a
STRING byte array. i.e.
...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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...
| |