
Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
I think it does not work.
Actually what I wanted is rather simple.
In C/C++, it is;
byte byteData[500] = .....
CString szMyString = (CString) byteData
It is that simple and straight forward because what is inside the byte array
is exactly the same char[]. Even a simple memcpy will work.
Any ideas on how to implement these simple object convertion?
>>I would like to ask on how to convert array of bytes, Byte[] into String?
>
> Use System.Text.Encoding (or one of the classes derived from it).
> Which encoding to use depends on what's on your byte array.
>
> Mattias
balmerch - 02 Dec 2005 20:16 GMT
I don't know if this is in the compact framework but try:
ASCIIEncoding.ASCII.GetString( myByteArray);
Make sure you include the System.Text namespace ("using System.Text;").
Chris
> I think it does not work.
>
[quoted text clipped - 17 lines]
> >
> > Mattias
EOS - 02 Dec 2005 20:23 GMT
I think it does not work on compact .net framework as the compilier error
show "No overload for method 'GetString' takes '1'1 arguments"
>I don't know if this is in the compact framework but try:
>
[quoted text clipped - 27 lines]
>> >
>> > Mattias
balmerch - 02 Dec 2005 20:35 GMT
Try this method signature then:
ASCIIEncoding.ASCII.GetString( myByteArray, 0, myByteArray.Length );
There are 2 method signatures for it on the full framework, since the first
isn't available on the CF, I assume the second must be.
Chris
> I think it does not work on compact .net framework as the compilier error
> show "No overload for method 'GetString' takes '1'1 arguments"
[quoted text clipped - 30 lines]
> >> >
> >> > Mattias
EOS - 03 Dec 2005 08:31 GMT
Thanks! It is working now. : )
> Try this method signature then:
>
[quoted text clipped - 40 lines]
>> >> >
>> >> > Mattias