PC Review


Reply
Thread Tools Rate Thread

Convert PHP pack() function to C#

 
 
gogaz@rediffmail.com
Guest
Posts: n/a
 
      7th Sep 2006
Hi,

PHP has a function called pack() (http://us2.php.net/pack). I need to
translate some code that uses this function to C#. What's the C#
equivalent of pack()?

Basically in php

$i = 1038;
pack("N", $i);

it converts string into binary string where first parameter
"N" is to convert it into unsigned long (always 32 bit, big endian byte
order)

I want similar in C#

Thanks

 
Reply With Quote
 
 
 
 
joachim@yamagata-europe.com
Guest
Posts: n/a
 
      7th Sep 2006

http://msdn.microsoft.com/library/de...int32topic.asp

Greets
Joachim

 
Reply With Quote
 
gogaz@rediffmail.com
Guest
Posts: n/a
 
      7th Sep 2006
Sorry, that didn't help at all!!!!

Can you please explain a bit more?

Regards

(E-Mail Removed) wrote:

> http://msdn.microsoft.com/library/de...int32topic.asp
>
> Greets
> Joachim


 
Reply With Quote
 
joachim@yamagata-europe.com
Guest
Posts: n/a
 
      7th Sep 2006
Sorry, I misunderstood the question, I thought you were just looking
for conversions:

Someone else posted your question on this forum:

http://forums.asp.net/thread/1244065.aspx

and he was pointed in this direction:

http://www.codeproject.com/dotnet/Bi...onversions.asp

I haven't seen any classes in .NET doing what pack does - then again
I never really had to do any operations on binary stuff - except for
colours.

Greets,
Joachim

 
Reply With Quote
 
Ben Voigt
Guest
Posts: n/a
 
      9th Sep 2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> PHP has a function called pack() (http://us2.php.net/pack). I need to
> translate some code that uses this function to C#. What's the C#
> equivalent of pack()?
>
> Basically in php
>
> $i = 1038;
> pack("N", $i);
>
> it converts string into binary string where first parameter
> "N" is to convert it into unsigned long (always 32 bit, big endian byte
> order)
>
> I want similar in C#


See System.BitConverter class.

Your example would be: Array.Reverse(BitConverter.GetBytes((Int32)i));

>
> Thanks
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can the "convert" function in excel convert to UK gallons? JR Microsoft Excel Misc 2 24th Apr 2008 04:55 PM
VbScript Function to encode into base64 compatible with .NET function System.Convert.FromBase64String abarberis@gmail.com Microsoft Dot NET Framework 1 20th Mar 2006 11:17 PM
Convert PHP pack() function to C# Brian Microsoft C# .NET 2 23rd Dec 2005 03:33 AM
function similar to pack() in php anoj Microsoft VB .NET 1 24th Dec 2004 12:42 PM
Pack & Go Function - Viewer not available MattH Microsoft Powerpoint 1 7th Nov 2003 02:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:13 AM.