开发者

Is there any library out there for c# that has the equivalent to "Unpack" in PHP and what is "Unpack"

I just want to convert a piece of PHP code to C# so I need it's equivale开发者_JS百科nt.

And what does unpack really do? I'm very interested in this function.


Unpack reads the binary data according to the data type you tell it to parse as and returns the values in an array.

The closest thing I can think to this would be to a struct within C(++) / C#, where it populates the struct's members with information from the binary data. A struct within C style languages is like an object, but without methods.

I can't think of any good examples right now on how to read data into a struct, but that's because I'm not really very good at C or C++ or C# for that matter. Try looking at this for examples on how to read data into structs ... or as always ... google it.


Public Shared Function unpack(str As String) As String

    Dim x As Integer
    Dim rstStr As String = ""
    For x = 0 To str.Length - 1
        rstStr &= Convert.ToString(Asc(str.Substring(x, 1)), 16)
    Next

    Return rstStr
End Function
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜