Hi,

I am a bit shocked that C# got nothing to do with C/C++.

Here is what I wanted to do;
Int32 f_nSomeValue = 200; // Supposed to be 4 bytes long in length, right?

MemoryStream f_MemoryStream = new MemoryStream(20);


f_MemoryStream.Write(&f_nSomeValue, 0 , 4);

The first param of the MemoryStream is expecting byte[ ]. I tried to cast it
but the complier would not let me to continue.

Does anyone know how do I convert the int32 so that it is can be used on the
MemoryStrem.Write( )?

Thanks for reading.

Re: How to return the pointer of int32 in C# .NET? by Jeroen

Jeroen
Mon Jun 06 10:41:06 CDT 2005


"Gravity" <gravity@nospam.org> wrote in message
news:u97lkNqaFHA.1152@tk2msftngp13.phx.gbl...
> Hi,
>
> I am a bit shocked that C# got nothing to do with C/C++.
>
> Here is what I wanted to do;
> Int32 f_nSomeValue = 200; // Supposed to be 4 bytes long in length,
> right?
>
> MemoryStream f_MemoryStream = new MemoryStream(20);
>
>
> f_MemoryStream.Write(&f_nSomeValue, 0 , 4);
>
> The first param of the MemoryStream is expecting byte[ ]. I tried to cast
> it but the complier would not let me to continue.


Try this:

f_MemoryStream.Write(BitConverter.GetBytes(f_nSomeValue), 0 , 4);


Best regards,

Jeroen Vandezande



Re: How to return the pointer of int32 in C# .NET? by Gravity

Gravity
Mon Jun 06 11:49:11 CDT 2005

Thanks for the quick reply. It works.

After learning C#, I hope I do not confuss with my current C/C++. There are
just so much differences.

"Jeroen Vandezande" <nospam@nospam.spam> wrote in message
news:et$yh4qaFHA.1384@TK2MSFTNGP09.phx.gbl...
>
> "Gravity" <gravity@nospam.org> wrote in message
> news:u97lkNqaFHA.1152@tk2msftngp13.phx.gbl...
>> Hi,
>>
>> I am a bit shocked that C# got nothing to do with C/C++.
>>
>> Here is what I wanted to do;
>> Int32 f_nSomeValue = 200; // Supposed to be 4 bytes long in length,
>> right?
>>
>> MemoryStream f_MemoryStream = new MemoryStream(20);
>>
>>
>> f_MemoryStream.Write(&f_nSomeValue, 0 , 4);
>>
>> The first param of the MemoryStream is expecting byte[ ]. I tried to cast
>> it but the complier would not let me to continue.
>
>
> Try this:
>
> f_MemoryStream.Write(BitConverter.GetBytes(f_nSomeValue), 0 , 4);
>
>
> Best regards,
>
> Jeroen Vandezande
>
>



Re: How to return the pointer of int32 in C# .NET? by Jeroen

Jeroen
Tue Jun 07 03:45:57 CDT 2005

"Gravity" <gravity@nospam.org> wrote in message
news:OOBcueraFHA.1384@TK2MSFTNGP09.phx.gbl...
> Thanks for the quick reply. It works.
>
> After learning C#, I hope I do not confuss with my current C/C++. There
> are just so much differences.

Yeah I know...
I also had to learn it the hard way... I come from delphi.
The trick is: If want to do something.. the chance is that there is a
function inside the .net framework to do it...
If you want to do low level bytemanipulations... take a good look at the
Bitconvertor Class... It's priceless.

Best Regards,

Jeroen Vandezande.


--
Join the Object Pascal Revolution - Get Chrome now!
http://www.ChromesVille.com